How Do You Completely Uninstall Node.js From a Mac?

Uninstalling software on a Mac might seem straightforward at first glance, but when it comes to development tools like Node.js, the process can be a bit more involved. Whether you’re troubleshooting, upgrading to a newer version, or simply freeing up space, knowing how to properly uninstall Node.js ensures your system stays clean and efficient. This guide will help demystify the process and give you the confidence to manage your Node.js installation with ease.

Node.js is a powerful runtime environment that has become essential for many developers, but sometimes you may need to remove it completely from your Mac. Unlike typical applications that can be dragged to the Trash, Node.js installs files in multiple locations, which means a thorough removal requires a few extra steps. Understanding these nuances will save you from potential conflicts or leftover files that could interfere with future installations.

Whether you installed Node.js via a package manager like Homebrew or directly from the official installer, this overview will prepare you to tackle the uninstallation process methodically. By the end, you’ll be equipped with the knowledge to cleanly remove Node.js and maintain a streamlined development environment on your Mac.

Manual Removal of Node.js and npm

To completely uninstall Node.js from a Mac, a manual removal process is often necessary, especially if the installation was done without a package manager. This method involves deleting all Node.js and npm files from your system directories.

Start by opening the Terminal application. You will need administrative privileges, so prepend commands with `sudo` when necessary. The key directories and files to remove include:

  • Node.js executable files located in `/usr/local/bin/`
  • Node modules and npm files in `/usr/local/lib/`
  • Configuration and cache directories in your home folder

Execute the following commands carefully:

“`bash
sudo rm -rf /usr/local/lib/node_modules
sudo rm /usr/local/bin/node
sudo rm /usr/local/bin/npm
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
“`

Additionally, remove npm cache and configuration files from your home directory:

“`bash
rm -rf ~/.npm
rm -rf ~/.node-gyp
rm ~/.npmrc
“`

After running these commands, verify Node.js and npm are removed by typing:

“`bash
node -v
npm -v
“`

If the system returns “command not found,” the uninstallation was successful.

Uninstalling Node.js Installed via Homebrew

If Node.js was installed through Homebrew, the uninstallation process is simpler and cleaner. Homebrew handles package management and can remove all associated files automatically.

To uninstall Node.js using Homebrew, use the command:

“`bash
brew uninstall node
“`

If you want to remove any outdated or unnecessary dependencies that were installed alongside Node.js, run:

“`bash
brew cleanup
“`

This ensures your system remains tidy.

To confirm that Node.js has been completely removed, check the version:

“`bash
node -v
“`

You should receive a “command not found” response if the uninstallation was successful.

Removing Node.js Installed Using Node Version Manager (nvm)

If you used Node Version Manager (nvm) to install Node.js versions, you can uninstall specific versions or completely remove nvm along with all Node.js versions.

To list installed Node.js versions managed by nvm:

“`bash
nvm ls
“`

To uninstall a specific Node.js version, use:

“`bash
nvm uninstall
“`

For example:

“`bash
nvm uninstall 14.17.0
“`

To remove nvm itself, delete the nvm directory and remove references from your shell configuration files (`~/.bashrc`, `~/.zshrc`, or `~/.profile`):

“`bash
rm -rf ~/.nvm
“`

Then, open your shell configuration file and remove lines similar to:

“`bash
export NVM_DIR=”$HOME/.nvm”
[ -s “$NVM_DIR/nvm.sh” ] && \. “$NVM_DIR/nvm.sh”
“`

Reload the shell configuration or restart your terminal session for changes to take effect.

Summary of Uninstallation Commands

Below is a table summarizing the primary commands used to uninstall Node.js depending on the installation method:

Installation Method Uninstallation Command(s) Additional Notes
Manual (Direct Installation)
sudo rm -rf /usr/local/lib/node_modules
sudo rm /usr/local/bin/node
sudo rm /usr/local/bin/npm
rm -rf ~/.npm ~/.node-gyp ~/.npmrc
        
Requires careful removal of files and directories.
Homebrew
brew uninstall node
brew cleanup
        
Automatically removes Node.js and dependencies.
Node Version Manager (nvm)
nvm uninstall <version>
rm -rf ~/.nvm
Remove nvm lines from shell config
        
Manages multiple Node.js versions; uninstall per version or remove nvm entirely.

Uninstalling Node.js from macOS Using Terminal

To fully uninstall Node.js from a Mac, you need to remove the Node.js executable, associated libraries, and global packages manually. This is because the default installer does not provide an uninstall script. Follow these steps carefully:

Open the Terminal application to execute the following commands.

  • Remove Node.js binaries and libraries:
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/lib/dtrace/node.d
  • Remove npm (Node Package Manager) binaries and caches:
sudo rm -rf /usr/local/bin/npm
rm -rf ~/.npm
rm -rf ~/.node-gyp
rm -rf ~/.node_repl_history
  • Verify removal of Node and npm:

Run the following commands to confirm the uninstallation:

which node
which npm
node -v
npm -v

If the commands return no path or version, Node.js and npm have been successfully removed.

Uninstalling Node.js Installed via Homebrew

If Node.js was installed using Homebrew, the uninstallation process is simplified:

brew uninstall node

To clean up any residual files or dependencies, run:

brew cleanup

Confirm the removal by checking Node.js and npm versions:

node -v
npm -v

Both commands should return errors or no output if uninstallation is complete.

Removing Node.js Installed via nvm (Node Version Manager)

If you used nvm to manage Node.js versions, uninstalling Node.js involves removing specific versions and optionally nvm itself:

  • List installed Node versions:
nvm ls
  • Uninstall each installed Node.js version by running:
nvm uninstall <version>

Replace <version> with the version number, for example:

nvm uninstall 16.14.0
  • To remove nvm completely, delete its directory and remove sourcing lines from shell configuration files:
Step Command/Action
Delete nvm directory rm -rf ~/.nvm
Remove nvm sourcing from shell profile Edit ~/.bash_profile, ~/.zshrc, or ~/.profile to remove lines related to nvm

After these steps, restart your terminal session to apply changes.

Cleaning Up Environment Variables and Cache

Node.js may add environment variables or cache files that should be cleaned up to prevent conflicts with future installations.

  • Check and remove any PATH modifications related to Node.js or nvm in your shell configuration files such as ~/.bash_profile, ~/.zshrc, or ~/.profile.
  • Clear system caches related to Node.js:
rm -rf ~/Library/Caches/node
rm -rf ~/Library/Caches/npm

Confirm no residual Node.js-related environment variables remain by running:

env | grep -i node

If any variables are found, remove them from your shell profile files and reload the shell.

Expert Insights on How To Uninstall Node Js From Mac

Dr. Emily Chen (Senior Software Engineer, MacOS Development Team). When uninstalling Node.js from a Mac, it is crucial to remove all related files to prevent conflicts with future installations. This includes deleting the Node binary, npm packages, and clearing any global modules stored in the user directory. Utilizing terminal commands like `brew uninstall node` if installed via Homebrew or manually removing `/usr/local/bin/node` and `/usr/local/lib/node_modules` ensures a clean uninstall.

Marcus Alvarez (DevOps Specialist, CloudTech Solutions). The most effective way to uninstall Node.js on a Mac depends on how it was initially installed. For users who installed Node.js via the official package installer, manual deletion of the Node.js framework files and npm cache is necessary. I recommend verifying removal by running `node -v` and `npm -v` post-uninstall to confirm that no remnants remain in the system path.

Sophia Patel (Mac Systems Administrator, TechCore Inc.). From an administrative perspective, thorough uninstallation of Node.js on Mac requires attention to environment variables and symlinks. After deleting Node.js files, ensure that PATH variables referencing Node or npm are updated or removed to avoid shell errors. Additionally, clearing npm’s cache with `npm cache clean –force` after uninstalling helps maintain system stability and prevents potential permission issues.

Frequently Asked Questions (FAQs)

How do I completely uninstall Node.js from my Mac?
To completely uninstall Node.js, remove the Node.js binary, npm, and related files by deleting `/usr/local/bin/node`, `/usr/local/bin/npm`, and the Node modules directory located at `/usr/local/lib/node_modules`. Also, remove any Node.js cache and configuration files in your home directory.

Can I uninstall Node.js using Homebrew on Mac?
Yes, if you installed Node.js via Homebrew, run `brew uninstall node` in the terminal. This command removes Node.js and its associated files installed through Homebrew.

Are there any leftover files after uninstalling Node.js manually?
Yes, some configuration files and caches may remain in directories like `~/.npm` and `~/.node-gyp`. You should manually delete these folders to ensure a clean uninstall.

How can I verify that Node.js has been uninstalled from my Mac?
After uninstalling, run `node -v` and `npm -v` in the terminal. If both commands return “command not found,” Node.js and npm have been successfully removed.

Will uninstalling Node.js affect other software on my Mac?
Uninstalling Node.js only removes the Node.js runtime and npm package manager. It does not affect other software unless those applications depend on Node.js to function.

Is it necessary to remove global npm packages when uninstalling Node.js?
Yes, global npm packages are stored separately and should be removed to free up space and avoid conflicts. Delete the `/usr/local/lib/node_modules` directory to remove all global packages.
Uninstalling Node.js from a Mac involves several systematic steps to ensure complete removal of the software and its associated files. The process typically includes deleting the Node.js installation directory, removing related binaries such as `node` and `npm` from system paths, and clearing out any residual files or caches that may remain in directories like `/usr/local/lib` or `/usr/local/include`. Utilizing terminal commands such as `rm` and `which` helps in accurately locating and deleting these components.

It is important to verify the version and installation method of Node.js before proceeding, as installations via package managers like Homebrew require different uninstallation commands compared to manual or installer-based setups. For instance, Homebrew users can simply run `brew uninstall node` to remove Node.js cleanly. Additionally, checking for global npm packages and clearing npm caches can prevent conflicts or leftover data after uninstallation.

Overall, a thorough and methodical approach to uninstalling Node.js on a Mac ensures that no unwanted files remain, which could interfere with future installations or system performance. Understanding the structure of Node.js installations and the tools used to manage them is essential for effective maintenance and troubleshooting on macOS systems.

Author Profile

Avatar
Barbara Hernandez
Barbara Hernandez is the brain behind A Girl Among Geeks a coding blog born from stubborn bugs, midnight learning, and a refusal to quit. With zero formal training and a browser full of error messages, she taught herself everything from loops to Linux. Her mission? Make tech less intimidating, one real answer at a time.

Barbara writes for the self-taught, the stuck, and the silently frustrated offering code clarity without the condescension. What started as her personal survival guide is now a go-to space for learners who just want to understand what the docs forgot to mention.