How to uninstall Node.js on Mac completely

How you uninstall Node.js on a Mac depends on how you installed it: with the installer from nodejs.org, with Homebrew or with nvm. Find out which one first, then remove that copy. Your projects stay where they are.

How was Node.js installed?

Open Terminal and run this command. It lists every copy of node Terminal can find, the one that runs first at the top:

which -a node
  • /usr/local/bin/node — the installer from nodejs.org. On an Intel Mac Homebrew uses this folder too, but only the nodejs.org installer leaves a receipt: pkgutil --pkg-info org.nodejs.node.pkg then prints its version.
  • /opt/homebrew/bin/node — Homebrew on a Mac with Apple silicon.
  • A path with .nvm/versions/node — nvm.

Several lines mean several copies. Remove each one the way its section below says.

How to uninstall Node.js installed from nodejs.org

The installer has no uninstaller, and nodejs.org gives no removal steps. What it put on the Mac is listed in its receipt (pkgutil --files org.nodejs.node.pkg), all in /usr/local. If you installed tools with npm install -g, list them with npm ls -g and remove each with npm uninstall -g and its name first: that also removes their commands from /usr/local/bin.

These commands delete Node.js, npm, npx and corepack, and every global npm package. Your projects and the npm cache in ~/.npm stay. Terminal asks for your Mac password:

sudo rm -f /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/corepack
sudo rm -rf /usr/local/lib/node_modules /usr/local/include/node /usr/local/share/doc/node
sudo rm -f /usr/local/share/man/man1/node.1

Then make macOS forget the installer’s receipts. This doesn’t touch any files:

sudo pkgutil --forget org.nodejs.node.pkg
sudo pkgutil --forget org.nodejs.npm.pkg

Uninstall Node.js installed with Homebrew

brew uninstall node

If you installed a version line like node@22, use that name: brew uninstall node@22. brew list shows what Homebrew has installed. This command then removes the formulas that were installed only as dependencies and aren’t needed anymore, the libraries Node.js used among them:

brew autoremove

nvm uninstall: remove a Node.js version installed with nvm

nvm keeps each version in ~/.nvm/versions/node. See which ones you have:

nvm ls

Remove a version by its number, here Node.js 20. Its global packages go with it:

nvm uninstall 20

nvm won’t remove the version in use and says «Cannot uninstall currently-active node version». Switch to another one with nvm use, or stop using nvm’s Node.js in this Terminal window with this command, then run nvm uninstall again:

nvm deactivate

Remove nvm itself

These commands delete nvm together with every Node.js version and global package it installed. Your projects stay:

nvm unload
rm -rf ~/.nvm
  1. Open your shell settings in TextEdit: run open -e ~/.zshrc in Terminal. If you use bash, the file is ~/.bash_profile or ~/.bashrc.
  2. Delete the lines nvm added: the one that starts with export NVM_DIR and the two below it that load nvm.sh and bash_completion.
  3. Save the file and open a new Terminal window.

Check that Node.js is gone

In a new Terminal window run the first command again. When it prints «node not found», no copy is left:

which -a node

The npm cache in ~/.npm is not removed with Node.js: see how to clear npm cache. To set Node.js up again, see how to install Node.js on Mac.

Keep your Mac tidy

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

MacWashing doesn’t uninstall Node.js or the versions nvm keeps: use the steps above. System Junk finds the npm, Yarn and pnpm caches your projects leave behind, next to the caches of your other apps, and shows how much each takes.

Free trial · macOS 14 or later

Questions and answers

How do I uninstall Node.js with nvm?

Run nvm ls to see the versions, then nvm uninstall with the version number. To remove nvm and all its versions, delete ~/.nvm and the nvm lines in ~/.zshrc.

Will uninstalling Node.js delete my projects?

No. Projects, their node_modules and lock files stay where they are. Global npm packages are removed together with the Node.js that installed them.

Why does node -v still work after I uninstalled Node.js?

Either another copy is left, installed a different way, or Terminal still runs the old one. Open a new Terminal window and run which -a node to see where it is.