keepcalculator

06 Numbers and Powers

Uninstall Node on Mac: Clean Removal Guide

Card No. 06·69012 · Updated · Standard formula, shown below

If you need to uninstall Node.js from your Mac, the safest method is to use the official installer’s uninstall script, or manually remove all Node-related files and directories. This article explains the complete process, what files to delete, and how to verify the removal, covering both globally installed packages and user-level configuration files.

Why Uninstall Node.js?

There are several common reasons you might want to remove Node.js from your Mac:

  • Version conflicts: You have multiple Node versions installed (e.g., via Homebrew, nvm, or the official pkg) and they are interfering with each other.
  • Clean slate: You want to reinstall Node.js fresh to clear out corrupted global packages or configuration issues.
  • Switching version managers: You are moving from the official installer to a version manager like nvm, fnm, or Volta.
  • Freeing disk space: Node.js and its global packages (especially those with heavy dependencies) can take up hundreds of megabytes.

Whatever your reason, a clean uninstall involves more than just dragging the app to the Trash. Node.js installs files in several locations, and leaving some behind can cause confusing errors later.

How Node.js Is Installed on macOS

Before you uninstall, it helps to know where Node.js files live. The exact locations depend on how you installed Node.js:

  • Official installer (.pkg): Installs to /usr/local/bin (or /opt/homebrew/bin on Apple Silicon), /usr/local/lib/node_modules, and /usr/local/include/node.
  • Homebrew: Installs to /opt/homebrew/Cellar/node (Apple Silicon) or /usr/local/Cellar/node (Intel), with symlinks in /opt/homebrew/bin or /usr/local/bin.
  • nvm (Node Version Manager): Installs to ~/.nvm and puts versions in ~/.nvm/versions/node.
  • fnm (Fast Node Manager): Installs to ~/.fnm.
  • Volta: Installs to ~/.volta.

Additionally, global packages are usually installed to /usr/local/lib/node_modules (or the corresponding prefix for your installation method), and npm caches data in ~/.npm. Knowing these paths is the first step to a complete removal.

Method 1: Using the Official Uninstall Script

If you installed Node.js using the official macOS installer (the .pkg file from nodejs.org), the easiest way to uninstall is to run the uninstall script that ships with that installer. Here’s how:

  1. Open Terminal (found in Applications/Utilities).
  2. Run the following command to download and execute the official uninstall script:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh -o uninstall.sh

Wait — that’s the Homebrew uninstall script, not Node’s. For Node specifically, the official .pkg installer does not include a public uninstall script. Instead, you can use the pkgutil command to see what the installer put on your system. A common approach is:

  1. List all files installed by the Node package:
pkgutil --files org.nodejs.node.pkg

This will output a list of every file and directory the installer created. You can then manually remove each one. However, this is tedious and error-prone. A more practical method is to use a third-party uninstaller like AppCleaner (free) or CleanMyMac (paid), which scans for related files. But for a reliable, manual approach, follow Method 2 below.

Method 2: Manual Removal (Works for Any Installation)

This method works regardless of how Node was installed, though it’s most thorough if you installed via the official pkg or Homebrew. Open Terminal and run these commands one by one. They will remove Node, npm, global packages, and related caches.

  1. Remove the main Node binary and npm:
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/npx

If you’re on Apple Silicon and installed via Homebrew, the paths might be /opt/homebrew/bin/node, /opt/homebrew/bin/npm, and /opt/homebrew/bin/npx.

  1. Remove the global node_modules directory (where global packages live):
sudo rm -rf /usr/local/lib/node_modules

On Apple Silicon, use /opt/homebrew/lib/node_modules.

  1. Remove the Node headers and include files:
sudo rm -rf /usr/local/include/node

Again, on Apple Silicon, use /opt/homebrew/include/node.

  1. Remove the npm cache and user-level configuration:
rm -rf ~/.npm
rm -rf ~/.node-gyp
rm -rf ~/.npmrc
  1. Remove the Homebrew symlinks (if you used Homebrew):
brew uninstall --ignore-dependencies node
brew prune

If you installed via Homebrew, it’s better to just run brew uninstall node first, then clean up any remaining files manually. The brew prune command removes stale symlinks.

  1. Remove the nvm directory (if you used nvm):
rm -rf ~/.nvm

If you used nvm, you’ll also want to remove the lines from your ~/.bashrc, ~/.zshrc, or ~/.profile that load nvm, otherwise you’ll get errors on every new terminal session.

  1. Remove the Volta directory (if you used Volta):
rm -rf ~/.volta

And similarly, remove any Volta lines from your shell config.

How to Verify Node Is Fully Uninstalled

After running the removal commands, you should verify that Node is completely gone. Here’s how:

  1. Close and reopen Terminal (to clear any cached PATH).
  2. Run node -v and npm -v. You should see command not found for both.
  3. Check for leftover directories:
ls -la /usr/local/bin/node
ls -la /usr/local/lib/node_modules
ls -la ~/.npm

If any of these return “No such file or directory”, you’re good. If they still exist, you can delete them with the appropriate rm -rf command.

Another useful check is to search for any remaining Node-related files:

sudo find / -name "node" -type f 2>/dev/null

This will list any files named “node” that are still on your system. Be careful — this will also find unrelated files, but it’s a good sanity check.

Common Problems and How to Avoid Them

Here are a few issues people often run into when uninstalling Node on a Mac:

  • Permission errors: Many Node files are owned by root, so you’ll need sudo to delete them. If you get “Operation not permitted”, make sure you’re using sudo.
  • Leftover global packages: If you don’t remove /usr/local/lib/node_modules, you’ll have orphaned packages that can cause conflicts if you reinstall Node later.
  • Shell config references: If you used nvm or Volta, forgetting to remove the initialization lines from your shell config will result in errors every time you open Terminal.
  • Homebrew dependencies: If you installed Node via Homebrew, other packages might depend on it. Running brew uninstall node will warn you if that’s the case, and you can use brew uninstall --ignore-dependencies node to force it, but be aware that other tools may break.

A common misconception is that deleting the Node.js app from the Applications folder is enough. That’s not true — Node.js is a command-line tool, so it doesn’t appear in the Applications folder at all. You must remove the binaries and libraries from the system directories.

What About Reinstalling Node.js Later?

If you plan to reinstall Node.js, consider using a version manager like nvm or fnm instead of the official installer. Version managers let you install multiple Node versions side-by-side and switch between them easily, which avoids the very conflicts that often lead people to uninstall in the first place.

To reinstall with nvm, you would run:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Then install the latest Node version with nvm install node. With fnm, you can use fnm install --lts. These tools keep everything in your home directory, so uninstalling later is as simple as removing that one folder.

Frequently Asked Questions

Do I need to uninstall Node before installing nvm?

No, you don’t have to, but it’s recommended. If you have a system-wide Node installation, nvm will take precedence in your PATH (as long as it’s loaded in your shell config), but having both can cause confusion. It’s cleaner to uninstall the system version first, then install nvm.

Will uninstalling Node delete my global npm packages?

Yes, if you remove the /usr/local/lib/node_modules directory (or the equivalent for your installation), all globally installed packages will be deleted. If you want to keep a list of them, run npm list -g --depth=0 before uninstalling and save the output.

Is it safe to delete the ~/.npm folder?

Yes, the ~/.npm folder is just a cache. Deleting it won’t break anything, but it will mean that the next time you run npm install, it will re-download packages from the registry, which can be slower.

What if I get “Error: EACCES: permission denied” when trying to remove files?

That error means you don’t have write permission to the file or directory. Use sudo before the rm command to run it with administrator privileges. You’ll be prompted for your password.

How do I uninstall Node if I installed it with the .pkg installer but can’t find the files?

Use the pkgutil --files org.nodejs.node.pkg command to list every file the installer placed. Then remove each one manually. If you prefer a GUI tool, AppCleaner can scan for leftover files after you drag the main binary to the trash.

Will uninstalling Node affect my other development tools?

Only if those tools depend on Node. For example, some editors like Visual Studio Code have built-in Node, but they don’t rely on the system Node. However, tools like ESLint, Prettier, or any globally installed CLI that you use will stop working. If you need them, reinstall them after reinstalling Node.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →