If you’ve installed Node.js on your Mac but no longer use it, you can uninstall it to free up space. The right steps depend on how you installed it: brew uninstall node removes a Homebrew installation, for example, but won’t remove a version installed with nvm. First, find out which copy of Node your Mac is using.
What is Node.js?
First, let’s take a closer look at what Node.js is and what it does, just in case you found it lurking on your Mac and do not recall installing it in the first place.
Node.js is a server-side JavaScript runtime environment that executes JavaScript instructions on a server and delivers the results to the web browser client. It runs on macOS, Windows, Linux, and other platforms. Some well-known organizations, such as Netflix, Microsoft, LinkedIn, and Amazon AWS, use it to deliver their online services. It’s built on Google’s Chrome V8 JavaScript engine but is open source and can be downloaded by anyone.
First, find out how Node was installed
Open Terminal (Applications > Utilities) and enter:
which -a node
The result gives you a starting point:
- A path inside
~/.nvm/versions/node/points to a version managed by nvm. /opt/homebrew/bin/nodeoften points to Homebrew on an Apple silicon Mac./usr/local/bin/nodecould come from Homebrew on an Intel Mac or from the official Node.js installer. Check before removing files.- More than one path means you may have more than one installation to remove.
To check for a Homebrew installation, run:
brew list --versions node
If you also use nvm, list its installed versions:
nvm ls
Run the commands for each installation method you find. If a command is unavailable, skip it and use the information you do have.
Before removing Node, save a list of your global npm packages. You may want to reinstall tools such as TypeScript or ESLint later:
npm list -g --depth=0 > ~/global-npm-packages.txt
If you have several Node versions installed with nvm, switch to each one and save its global npm package list. Each version may have different packages, so you’ll need those lists if you want to reinstall them later.
If you installed Node with Homebrew
If brew list --versions node shows an installed version, run:
brew uninstall node
If another Homebrew package depends on Node, Homebrew may stop the uninstall and show a warning. Check which package needs Node before deciding what to remove.
To clear old Homebrew downloads and outdated formula versions, you can then run:
brew cleanup
This cleans Homebrew’s files, but it does not clear your npm cache or remove an nvm installation. You can check for npm files separately in the leftover cleanup section below. Homebrew documents uninstall and cleanup as distinct commands.
If you installed Node with nvm
List your installed versions:
nvm ls
If the version you want to remove is active, switch away from it first:
nvm deactivate
Then uninstall it using the version number shown by nvm ls:
nvm uninstall v20.19.0
Repeat for any other nvm-managed versions you want to remove. Keep nvm if you plan to use it again.
If you want to remove nvm itself, unload it from the current Terminal session:
nvm unload
Then remove its installation folder, provided you used the default ~/.nvm location:
rm -rf ~/.nvm
Next, open your shell configuration file—usually ~/.zshrc—and delete the lines that mention NVM_DIR or load nvm.sh. If you don’t find them there, check ~/.bash_profile or any other shell file you’ve used. These lines need to go when you remove nvm completely.
If you used the official Node.js installer
Use this section only after checking that /usr/local/bin/node belongs to the Node.js installer rather than Homebrew or another tool. If Homebrew is installed in /usr/local, check its records first:
brew list --versions node
If you installed Node.js using the official macOS installer, its files are usually in /usr/local. To remove Node, npm, and npx, run:
sudo rm -f /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/npx
Then remove the Node headers and the installer’s npm folder, after checking that you no longer need anything in those locations:
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/lib/node_modules/npm
Other global packages may remain in /usr/local/lib/node_modules. Inspect that folder before deleting anything else:
ls -la /usr/local/lib/node_modules
The installer can also leave package receipts. Check which Node receipts your Mac has:
pkgutil --pkgs | grep 'org.nodejs'
If you find org.nodejs.node.pkg or org.nodejs.npm.pkg, you can remove their receipts after removing the corresponding installed files:
sudo pkgutil --forget org.nodejs.node.pkg
sudo pkgutil --forget org.nodejs.npm.pkg
Only run --forget for receipts you found in the previous step. It removes the installation record, not the Node files. The Node.js installer uses separate receipts for Node and npm.
Remove npm caches and other leftovers
The steps above can leave files in your Home folder. Check them before removal, especially if you plan to reinstall Node or use another Node installation.
Your npm cache is commonly stored at ~/.npm. If you no longer need its downloaded packages and logs, remove it with:
rm -rf ~/.npm
Check for an npm configuration file too:
ls -la ~/.npmrc
If you find a .npmrc file, check what’s in it before deleting it. It may contain registry settings or login details you still need. You can also look for old build files and Node command history:
ls -ld ~/.node-gyp ~/.node_repl_history 2>/dev/null
Remove only the files you recognize and no longer want. If you are keeping another Node installation, leave its files in place. npm notes that removing npm can leave globally installed packages behind and that their location depends on the installation prefix.
Check developer files with CleanMyMac CLI
If you also want to review developer caches left on your Mac, CleanMyMac CLI can scan caches from npm and other developer tools. Install it with Homebrew if needed:
brew install --cask cleanmymac-cli
Then run:
cleanmymac clean dev
Review the items it finds before choosing what to remove. To look for removable node_modules folders and other generated files in common project locations, run:
cleanmymac purge
These commands help with developer caches and project files. They do not replace the installation steps above or verify that Node, nvm, shell settings, and package receipts have all been removed.
Check that Node.js is gone
Close Terminal, open a new window, and run:
node -v
npm -v
which -a node
If Node and npm are gone, the version commands should report that they cannot be found, and which -a node should show no path. If you still get a version or a path, you likely have another installation. Check that path and return to the matching section above.
Uninstalling Node usually removes the npm command installed with it. Your npm cache, settings, global packages, and project folders may still be there, so check those separately if you want to clear them out.
How to uninstall other apps & remove leftovers
How to uninstall other apps easily
As you can see, uninstalling Node.js can involve several steps. If you also have Mac apps you no longer use, removing them manually can mean tracking down their related files one by one.
However, there is a more effortless way, thanks to a handy application called CleanMyMac. Among many other valuable tools, CleanMyMac has an Uninstaller tool that takes all the work out of uninstalling apps. You can start a free trial here.
Once you’ve downloaded it, follow the steps below to uninstall an application.
- Open CleanMyMac and navigate to the Applications module in the left sidebar.
- Click a Scan button for a quick overview of all the applications, updates, and leftovers.
- Once complete, click Manage My Applications, where you’ll find the Uninstaller tool. Select the applications you want to uninstall and check the button next to the application’s name.
- Click Uninstall.
How to remove application leftovers
Remember we mentioned earlier that if you have moved an application binary to the Trash, you still need to remove leftovers? Well, you can do that using CleanMyMac, too.
- Once you click on the Applications module in the left sidebar and run a scan, navigate to Manage My Applications.
- Select the Leftovers tool in the sidebar to view residual files categorized under Installers and Leftover Files.
- Simply check the boxes next to the leftovers you want to remove in the right pane.
- Click Remove.
These tools are for Mac apps and their associated files. To remove Node.js itself, use the steps for your installation method above.