How to fully uninstall Node.js on Mac
Node.js scatters files across system directories depending on how you installed it — pkg installer, Homebrew, or nvm. The npm cache alone can grow to several gigabytes. Here's how to remove everything.
8+
Leftover locations
500 MB – 5 GB
Typical leftover size
npm/yarn globals persist
Global packages
What Node.js leaves behind
Node.js scatters files across system directories depending on your installation method. The npm cache alone can grow to several GB, and globally installed packages persist in /usr/local/lib/node_modules/ even after removing the Node.js binary:
| Location | Contents |
|---|---|
| /usr/local/bin/node | Node.js binary (pkg installer) |
| /usr/local/bin/npm | npm binary |
| /usr/local/bin/npx | npx binary |
| /usr/local/lib/node_modules/ | Global npm packages |
| /usr/local/include/node/ | Node.js header files |
| ~/.npm/ | npm cache directory (can be 1–5+ GB) |
| ~/.nvm/ | Node Version Manager directory (if using nvm) |
| ~/.node-gyp/ | Native addon build cache |
Note: Zapper is designed for macOS .app bundles. For developer tools like Node.js, manual removal via Terminal is the best approach.
Uninstalling by installation method
First, determine how Node.js was installed by running which node in Terminal.
Pkg installer (/usr/local/bin/node)
If you installed Node.js from the official nodejs.org .pkg installer, you need to remove the binaries and directories manually:
- 1. Remove Node.js binariesRun in Terminal:
sudo rm /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx - 2. Remove Node.js directoriesRun:
sudo rm -rf /usr/local/lib/node_modules/ /usr/local/include/node/ - 3. Remove additional filesRun:
sudo rm -rf /usr/local/share/doc/node /usr/local/share/man/man1/node.1
Homebrew (/opt/homebrew/bin/node)
If you installed Node.js via Homebrew, removal is straightforward:
- 1. Uninstall Node.jsRun in Terminal:
brew uninstall node - 2. Clean up Homebrew cacheRun:
brew cleanup
nvm (~/.nvm)
If you used Node Version Manager, all Node.js versions live inside ~/.nvm:
- 1. Deactivate nvmRun in Terminal:
nvm deactivate - 2. Remove the nvm directoryRun:
rm -rf ~/.nvm - 3. Remove nvm config from shell profileEdit your
~/.zshrcor~/.bash_profileand remove the lines that load nvm.
Cleaning up npm and global packages
Regardless of installation method, npm leaves behind cache and configuration files in your home directory:
- 1. Delete the npm cacheThe
~/.npm/directory stores cached packages and can grow to several GB. Run:rm -rf ~/.npm - 2. Delete node-gyp build cacheNative addon builds are cached in
~/.node-gyp/. Run:rm -rf ~/.node-gyp - 3. Remove global node_modulesIf you haven't already, remove
/usr/local/lib/node_modules/. Run:sudo rm -rf /usr/local/lib/node_modules - 4. Remove npm/yarn config files (optional)Delete
~/.npmrcand~/.yarnrcif they exist.
Verify complete removal
After completing the steps above, verify that Node.js and npm are fully removed by running these commands in Terminal:
which node
which npm
node --version
All three commands should return "not found" or produce no output. If any command still returns a path, check that location and remove the remaining files. You may need to restart your Terminal or run hash -r to clear the shell's command cache.
Note: Node.js is a CLI tool, not a .app bundle — Terminal is the right way to remove it. But if you're also cleaning up regular Mac apps, Zapper finds and removes all their hidden leftover files automatically.