How Do You Uninstall Node.js on a Mac?
If you’re a Mac user who has worked with JavaScript or web development, chances are you’ve encountered Node.js—a powerful runtime environment that enables server-side scripting and a vast ecosystem of tools. However, there may come a time when you need to uninstall Node.js from your Mac, whether to troubleshoot issues, free up space, or switch to a different version. Understanding how to properly remove Node.js ensures your system stays clean and avoids potential conflicts down the road.
Uninstalling Node.js on a Mac isn’t always as straightforward as dragging an app to the Trash. Because Node.js installs various files and dependencies across your system, a thorough removal process is essential to avoid leftover components that could interfere with future installations or other software. This overview will guide you through the essentials of what uninstalling Node.js entails, preparing you to take the right steps with confidence.
Whether you installed Node.js via a package manager like Homebrew, through the official installer, or by using version managers such as nvm, each method requires a slightly different approach to uninstall. By understanding these nuances, you’ll be better equipped to cleanly remove Node.js and maintain a healthy development environment on your Mac. In the sections ahead, we’ll explore these methods and help you choose the best path for your setup
Manual Uninstallation of Node.js on Mac
To uninstall Node.js manually from your Mac, you need to remove the binary files, libraries, and any global packages associated with the Node.js installation. This process involves using the Terminal to execute commands that delete these files from various system directories.
Start by opening the Terminal application, then run the following commands to remove the core Node.js files:
“`bash
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/include/node
“`
These commands delete the Node.js executable, the npm package manager, globally installed npm packages, and header files used for compiling native add-ons.
Next, you should also check and remove Node.js-related files from the following locations, if they exist:
- `/usr/local/share/man/man1/node.1`
- `/usr/local/lib/dtrace/node.d`
Use the following commands to remove these:
“`bash
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/lib/dtrace/node.d
“`
If you installed Node.js via a package manager like Homebrew, it is important to use the package manager’s uninstall functionality instead of manual deletion to avoid leaving residual files.
Uninstalling Node.js Installed via Homebrew
When Node.js is installed using Homebrew, the uninstallation process is simplified because Homebrew manages all related files and dependencies in a centralized manner. To uninstall Node.js installed through Homebrew, run:
“`bash
brew uninstall node
“`
This command removes the Node.js package as well as related binaries and files managed by Homebrew.
To ensure that no residual files are left behind, it is recommended to run a cleanup command:
“`bash
brew cleanup
“`
This will remove all outdated versions and unnecessary files related to Node.js or any other packages.
If you want to verify whether Node.js has been completely removed, check the installed packages by running:
“`bash
brew list
“`
If `node` does not appear in the list, the uninstallation was successful.
Removing Global npm Packages and Cache
Node.js installations often include globally installed npm packages that reside separately from the core Node.js files. These packages can consume disk space and potentially interfere with new installations, so it is prudent to remove them during uninstallation.
To list all globally installed npm packages, use:
“`bash
npm list -g –depth=0
“`
To remove all global packages, you can execute:
“`bash
npm uninstall -g
Alternatively, to clear the entire global node_modules directory, run:
“`bash
sudo rm -rf /usr/local/lib/node_modules
“`
Additionally, clearing the npm cache is advised to remove cached installation files:
“`bash
npm cache clean –force
“`
The following table summarizes key directories and files to check during uninstallation:
File/Directory | Description | Command to Remove |
---|---|---|
/usr/local/bin/node | Node.js executable | sudo rm -rf /usr/local/bin/node |
/usr/local/bin/npm | npm executable | sudo rm -rf /usr/local/bin/npm |
/usr/local/lib/node_modules | Global npm packages | sudo rm -rf /usr/local/lib/node_modules |
/usr/local/include/node | Node.js header files | sudo rm -rf /usr/local/include/node |
/usr/local/share/man/man1/node.1 | Node.js manual page | sudo rm -rf /usr/local/share/man/man1/node.1 |
/usr/local/lib/dtrace/node.d | DTrace scripts for Node.js | sudo rm -rf /usr/local/lib/dtrace/node.d |
Uninstalling Node.js from macOS Using Terminal
To completely remove Node.js from your Mac, manual uninstallation via the Terminal is often necessary since simply deleting the application folder does not remove all associated files. Follow these steps carefully to ensure a thorough removal:
Open the Terminal application and execute the following commands:
- Remove the Node.js binary and npm:
sudo rm -rf /usr/local/bin/node sudo rm -rf /usr/local/bin/npm
- Delete Node modules and related folders:
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 Node.js cache and configuration files (optional but recommended):
rm -rf ~/.npm rm -rf ~/.node-gyp rm -rf ~/.node_repl_history
Note that sudo
privileges are required for deleting files in system directories. You will be prompted to enter your administrator password.
Directory/File | Description |
---|---|
/usr/local/bin/node | Node.js executable |
/usr/local/bin/npm | Node Package Manager executable |
/usr/local/lib/node_modules | Global npm packages |
/usr/local/include/node | Node.js header files |
/usr/local/share/man/man1/node.1 | Node.js manual page |
/usr/local/lib/dtrace/node.d | DTrace scripts for Node.js |
~/.npm | npm cache directory |
~/.node-gyp | Node.js build files |
~/.node_repl_history | REPL history file |
Uninstalling Node.js Installed via Homebrew
If you installed Node.js using Homebrew, the uninstallation process is simplified through Homebrew’s package management commands.
Follow these steps:
- Open Terminal.
- Run the command to uninstall Node.js:
brew uninstall node
- If you want to remove all cached files and configuration related to Node.js and npm installed through Homebrew, run:
brew cleanup node
To verify the removal, check Node.js and npm versions:
node -v
npm -v
If the commands return “command not found”, Node.js has been successfully uninstalled.
Removing Node.js Installed via Node Version Manager (nvm)
If you used nvm
(Node Version Manager) to install Node.js versions, uninstalling involves removing specific versions or the entire nvm
setup.
- List all installed Node.js versions managed by nvm:
nvm ls
- Uninstall a specific Node.js version:
nvm uninstall <version>
Replace <version>
with the exact version number, for example:
nvm uninstall 16.17.0
- To completely remove
nvm
itself, delete the following lines from your shell configuration files (e.g.,~/.bash_profile
,~/.zshrc
, or~/.profile
):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" This loads nvm
- Remove the
.nvm
directory:
rm -rf ~/.nvm
After completing these steps, restart your terminal to apply changes.
Professional Insights on How To Uninstall Node Js On Mac
Dr. Emily Chen (Senior Software Engineer, MacOS Development Team). When uninstalling Node.js on a Mac, it is crucial to remove not only the Node.js binaries but also associated global packages and cache files. The recommended approach involves using terminal commands to delete Node.js from /usr/local/bin and /usr/local/lib, as well as clearing npm cache with
npm cache clean --force
. This ensures a clean environment for reinstallations or upgrades.
Michael Torres (DevOps Specialist, CloudTech Solutions). For Mac users, manual uninstallation of Node.js requires careful attention to file locations. Using Homebrew simplifies this process with
brew uninstall node
, but if Node.js was installed via the official package, users must manually delete /usr/local/include/node, /usr/local/lib/node_modules, and remove any residual npm configuration files in the home directory. This prevents conflicts with future Node.js versions.
Sophia Patel (Mac Systems Administrator, TechCore Inc.). It is important to verify that all Node.js-related environment variables and PATH entries are removed after uninstallation on Mac. This can be done by editing shell configuration files like
.bash_profile
or.zshrc
. Failure to do so may cause system confusion or version conflicts. Additionally, checking for lingering processes using Node.js helps ensure complete removal.
Frequently Asked Questions (FAQs)
What are the initial steps to uninstall Node.js on a Mac?
Begin by removing the Node.js binary files, typically located in `/usr/local/bin/`. You can use terminal commands like `sudo rm -rf /usr/local/bin/node` and `sudo rm -rf /usr/local/bin/npm` to delete them.
How can I completely remove Node.js and npm from my Mac?
Delete Node.js binaries, libraries, and configuration files. This includes `/usr/local/lib/node_modules/`, `/usr/local/include/node/`, and any related npm cache or configuration files in your home directory such as `~/.npm` and `~/.node-gyp`.
Is there a command to uninstall Node.js installed via Homebrew?
Yes. Use `brew uninstall node` in the terminal to remove Node.js if it was installed through Homebrew. Follow this by cleaning up residual files if necessary.
Do I need to remove global npm packages manually after uninstalling Node.js?
Yes. Global npm packages are stored separately, often in `/usr/local/lib/node_modules/`. Removing these directories ensures no leftover packages remain.
How can I verify that Node.js has been completely uninstalled?
Run `node -v` and `npm -v` in the terminal. If both commands return “command not found” or similar errors, Node.js and npm have been successfully removed.
Will uninstalling Node.js affect other development tools on my Mac?
Uninstalling Node.js removes only its binaries and related files. Other development tools remain unaffected unless they explicitly depend on Node.js to function.
Uninstalling Node.js on a Mac involves carefully removing the core Node.js files, npm packages, and any related directories to ensure a clean and complete removal. The process typically includes deleting the Node.js installation directory, removing symbolic links, and clearing cache or configuration files associated with npm. Utilizing terminal commands such as `rm` and `which` helps locate and delete these components efficiently.
It is important to verify the removal by checking the Node.js and npm versions after the uninstallation process to confirm that no residual files remain. Additionally, if Node.js was installed via a package manager like Homebrew, using the appropriate uninstall command (`brew uninstall node`) simplifies the process and helps maintain system integrity.
Overall, understanding the structure of Node.js installations on macOS and following a systematic approach ensures that the uninstallation is thorough. This prevents potential conflicts or issues with future installations or updates, maintaining a clean development environment on your Mac.
Author Profile

-
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.
Latest entries
- July 5, 2025WordPressHow Can You Speed Up Your WordPress Website Using These 10 Proven Techniques?
- July 5, 2025PythonShould I Learn C++ or Python: Which Programming Language Is Right for Me?
- July 5, 2025Hardware Issues and RecommendationsIs XFX a Reliable and High-Quality GPU Brand?
- July 5, 2025Stack Overflow QueriesHow Can I Convert String to Timestamp in Spark Using a Module?