Uninstalling Node.js in Windows
To remove Node.js from Windows, follow these steps:
Step 1: Uninstall Node.js via Control Panel
- Open the Control Panel.
- Navigate to Programs > Programs and Features.
- Scroll down and locate Node.js.
- Click on it and select Uninstall.
- Follow the on-screen instructions to complete the uninstallation process.
Step 2: Remove Node.js Folders
Even after uninstalling Node.js, some residual files may remain. Remove them manually:
- Open File Explorer and navigate to the following directories:
- C:\\Program Files\\nodejs
- C:\\Users\\<YourUsername>\\AppData\\Roaming\\npm
- C:\\Users\\<YourUsername>\\AppData\\Roaming\\nvm
- Delete these folders to remove all traces of Node.js.
Step 3: Remove Environment Variables
- Open the Start Menu, search for Environment Variables, and open it.
- In the System Properties window, click on Environment Variables.
- Under System variables, find Path and click Edit.
- Remove any paths related to Node.js and npm (e.g., C:\\Program Files\\nodejs\\ and C:\\Users\\<YourUsername>\\AppData\\Roaming\\npm).
- Click OK to save changes.
Uninstalling Node.js in Ubuntu
If you have installed Node.js using apt, nvm, or snap, follow these methods to uninstall it:
Method 1: Uninstall Node.js using apt (For apt-based Installation)
Run the following command to remove Node.js:
sudo apt remove nodejs -y
To remove additional related files:
sudo apt autoremove -y
sudo apt purge nodejs -y
Method 2: Remove Node.js Installed via nvm
If you installed Node.js using Node Version Manager (nvm), use the following commands:
nvm deactivate
nvm uninstall <version>
To remove nvm completely:
rm -rf ~/.nvm
Also, remove related lines in the ~/.bashrc, ~/.bash_profile, or ~/.zshrc file.
Method 3: Remove Node.js Installed via Snap
If you installed Node.js via snap, remove it using:
sudo snap remove node
Uninstalling Node.js on Mac
To remove Node.js from macOS, use one of these methods depending on how it was installed:
Method 1: Uninstalling Node.js Installed via Homebrew
Run the following command in Terminal:
brew uninstall node
To remove leftover files:
rm -rf ~/.npm
rm -rf ~/.node-gyp
Method 2: Uninstalling Node.js Installed via Installer
Open Terminal and run:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/share/man/man1/node*
Verify removal:
node -v
If the output is “command not found”, Node.js has been successfully uninstalled.
Frequently Asked Questions
Why would I need to uninstall Node.js?
There are several reasons you might need to uninstall Node.js, such as switching to a different version, resolving conflicts with other software, or freeing up system resources if you no longer need it.
Can I reinstall Node.js after uninstalling it?
Yes, you can reinstall Node.js anytime by downloading it from the official website or using package managers like apt, brew, or nvm.
Will uninstalling Node.js remove npm as well?
Yes, npm (Node Package Manager) is bundled with Node.js, so uninstalling Node.js will remove npm too.
Conclusion
In this article, we covered different methods to uninstall Node.js from Windows, Ubuntu, and macOS. We also learned how to remove residual files and clean up the system completely. Whether you are switching to a different version of Node.js or no longer need it, these steps will help ensure a proper uninstallation process.