Last Updated :
07 Jun, 2024
We can remove the nodejs from window by uninstalling it from the programs list. Node.js is a popular JavaScript runtime used for building server-side applications. However, there may come a time when you need to remove Node.js from your Windows system completely. Whether it’s due to a corrupted installation, needing to install a different version, or simply not needing it anymore, here’s a comprehensive guide to uninstall Node.js from your Windows machine.
Steps to Completely Remove Node.js from Windows
Step 1: Whenever we install a package with the command npm install <package name>, npm stores the cache inside the user file system. The default directory where the cache data is stored on Windows is %AppData%/npm-cache. So, we need to clean the cache first. The cache can be cleaned by using the following command.
npm cache clean --force
Step 2: After that, you can verify the cache by using the below command:
npm cache verify
Step 3: Now open the control panel in the computer. Search for Program and features. Under the program and features click on Uninstall a program. Now search for Node.js and uninstall it.
Step 4: Restart your computer or kill all node-related processes from Task Manager.
Step 5: Look for folder in your computer and if they are present remove them. The folders and files may or may not exist in your computer depending on various factors like installed version or CPU architecture.
- C:\Program Files (x86)\Nodejs
- C:\Program Files\Nodejs
- C:\Users\{User}\AppData\Roaming\npm or open run and type appdata and click ok and open roaming there you will find npm.
- C:\Users\{User}\AppData\Roaming\npm-cache or open run and type appdata and click ok and open roaming there you will find npm-cache.
- C:\Users\{User}\.npmrc
- C:\Users\{User}\package.json
- C:\Users\{User}\package-lock.json
- C:\Users\{User}\AppData\Local\Temp\npm-*
Step 6: After that check the environment path variables and make sure no references to npm or Node.js exist.
Step 7: If Node.js is still not uninstalled then open the command prompt and type the below command:
where node
Step 8: If Node.js is not uninstalled the command will output the location of Node.js. Go to that location and uninstall the directory.
Step 9: Restart the computer. Node.js is now completely uninstalled.
Conclusion
By following these steps, you should have completely removed Node.js and npm from your Windows system. This thorough process ensures that no residual files or environment variables are left behind, which is especially important if you plan to reinstall Node.js or switch to a different version. If you encounter any issues during the removal process, restarting your computer and repeating the steps can help resolve them.
It is important to uninstall Node.js properly to maintain system stability, free up space, or prepare for a fresh installation. You may need to uninstall Node.js when switching versions, troubleshooting issues, or clearing system clutter. Knowing how to delete NodeJS correctly ensures that all components, including npm, are removed without leaving behind residual files or affecting future installations. And by the way, if you’re uninstalling because you’re looking to hire remote NodeJS developer, we have the right resources to scale up your team!
Preparing for Uninstallation
Before you uninstall Node.js, follow these steps:
- Back-Up Your Files: Save any important data or project files related to Node.js, including configurations within your IDE Node.js setup if you’re using one. This helps preserve settings you may want to reuse later.
- Check Versions: Make sure you know which versions of Node.js and npm are installed.
- How to Check:
- Open the terminal or command prompt.
- Type node -v and press Enter to see the Node.js version.
- Type npm -v and press Enter to see the npm version.
- How to Check:
- Proceed with Uninstallation: Once you have backed up your files and noted the versions, you can safely uninstall Node.js.
This ensures you don’t lose important information and remove the correct versions from your system.
Uninstallation Steps for Windows
Uninstalling Node.js on Windows involves a lot of steps to ensure that all components are completely removed. Make sure to follow each step to avoid leaving behind any residual files.
Step 1: Clear npm Cache
To begin, clear all cached data stored by npm using the command npm cache clean –force. This ensures no leftover cache files interfere with future installations or affect system performance.
Step 2: Verify Cache Clearance
Once the cache is removed, make sure to run npm cache verify to confirm.
Step 3: Uninstall Node.js Application
To uninstall Node.js:
- Open the Control Panel.
- Click on “Programs and Features.”
- Find and select “Node.js” from the list.
- Click the “Uninstall” button.
This will remove Node.js from your computer.
Step 4: End Node.js Processes
Open Task Manager (Ctrl + Shift + Esc) and check for any Node.js processes that might be running. If any are active, end them to prevent interference during uninstallation. Alternatively, restarting the system can help clear all Node.js processes.
Step 5: Remove Node.js Environment Variables
Open System Properties.
Go to the Advanced tab and click on ‘Environment Variables’.
Find and remove any Node.js paths, such as
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm
C:\Users\{User}\AppData\Roaming\npm-cache
C:\Users\{User}\.npmrc
C:\Users\{User}\package.json
C:\Users\{User}\package-lock.json
C:\Users\{User}\AppData\Local\Temp\npm-*
To access the directories, type appdata in the Run dialog (Win + R), then navigate to Roaming.
Step 6: Apply Changes
After removing the environment variables, ensure all changes are saved by clicking “OK” to close each dialog box.
Step 7: Verify Uninstallation
Finally, make sure Node.js is fully removed by opening the command prompt and typing where node. If any Node.js directories still exist, manually navigate to the paths and delete them.
Uninstallation Steps for Linux (Ubuntu)
This section outlines the steps to uninstall Node.js on Ubuntu systems. Carefully execute each step to ensure a thorough uninstallation.
Step 1: Remove Node.js
To uninstall Node.js on Ubuntu, open the terminal and enter:
sudo apt-get remove nodejs
Step 2: Remove npm
To uninstall npm and Node.js, enter this command in the terminal:
sudo apt-get remove npm
This will remove both npm and Node.js from your system.
Step 3: Clean Up Residual Files
Follow Step 7 from the Windows section. Check for residual folders and files by running whereis node. Any remaining files related to Node.js should be manually deleted to ensure a clean removal.
Uninstallation Steps for macOS
Uninstalling Node.js on macOS can be done in two ways- using Homebrew or manually deleting files. This section covers both methods to ensure a thorough removal.
Step 1: Remove Node.js and npm
To uninstall Node.js installed with Homebrew, open your terminal and run:
brew uninstall node
If you installed Node.js manually, you can remove it and npm by deleting these folders:
/usr/local/bin/node
/usr/local/lib/node_modules
Simply navigate to these directories and delete them to complete the uninstallation.
Step 2: Remove Residual Files
Type the following commands to delete any leftover Node.js folders after opening the terminal:
rm -rf /usr/local/bin/node
rm -rf /usr/local/bin/node_modules
rm -rf ~/.npm
rm -rf ~/.node-gyp
Step 3: Clean Up Environment Variables
Check your shell profile files (e.g., .bash_profile, .zshrc) for any environment variables related to Node.js. Edit the files and remove any Node.js references to ensure no environment variables remain.
Verifying Complete Uninstallation
To ensure a complete uninstallation, use system commands such as where node (on Windows) or where is node (on Linux) to check for any remaining Node.js files or directories. Manually inspect and delete any residual folders or environment variables. These steps are important to make sure Node.js is completely removed from your computer. Now that you have deleted NodeJS maybe try switching to Python for your web app development needs.
As you clean up your system, you might explore advanced use cases like node js app development, especially if you’re considering a fresh stack for mobile or full-stack applications.
Troubleshooting
Issues can easily arise during the uninstallation process. For example, leftover files may prevent a clean uninstall or certain processes may remain active. If you encounter problems, use Task Manager (Windows) or Terminal (Linux/macOS) to terminate any Node.js processes and manually remove residual files.
Conclusion
In this guide, we’ve discussed how to delete NodeJS from Windows, Linux, and macOS systems, covering all the necessary steps to ensure a clean uninstallation. Following these best practices will leave your system free from residual files and processes, keeping it in optimal condition for future development needs. And if you ever change your mind, Soft Suave app development services are always here to help you with your next big project!
Table of Contents
- Manual Removal
- Conclusion
In this post, we’ll learn how to uninstall Node and NPM on Windows.
The first thing you should do is clear your NPM cache. This is a good idea to do before you uninstall Node as it will remove any information that Node has cached about your dependencies.
To clear your NPM cache, run the following command:
BASH
npm cache clean --force
From there, go to your Control Panel. You can do this by searching for Control Panel in the search bar.
Once there, select the Programs and Features option.
Then, find and select Node.js and click the Uninstall button.
This will begin the uninstallation process.
After this has finished, restart you computer so the changes can take effect.
Once you’ve restarted your computer, you should be able to run the following command to confirm that Node and NPM have been uninstalled:
BASH
node -v
npm -v
If your system cannot recognize or find these commands, then it means you’ve successfully uninstalled Node and NPM on your Windows system.
Manual Removal
If after running the above commands, you still see the Node and NPM commands return a valid version, then might need to manually remove them.
To do so, remove everything in the following directories:
BASH
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{Username}\AppData\Roaming\npm
C:\Users\{Username}\AppData\Roaming\npm-cache
Or if you prefer to use the %appdata% environment variable, you can use these directories:
BASH
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
%appdata%\npm
%appdata%\npm-cache
Once again, restart your computer so the changes can take effect.
Conclusion
We’ve seen how to uninstall Node and NPM on Windows.
Hopefully, you able to complete these steps successfully and uninstall Node and NPM from your Windows system!
To learn more about web development, founding a start-up, and bootstrapping a SaaS, follow me on X!
By Filip on 04/19/2024
Learn how to completely uninstall Node.js and npm from your Windows system, including removing leftover files and environment variables, for a clean slate.
Table of Contents
- Introduction
- Step-by-Step Solution
- Code Example
- Additional Notes
- Summary
- Conclusion
- References
Introduction
This guide provides a comprehensive walkthrough on how to completely uninstall Node.js and npm from your Windows system. It covers using the Control Panel, clearing the npm cache, manually deleting leftover files, checking environment variables, and restarting your computer. Additional notes address using package managers and troubleshooting potential issues.
Step-by-Step Solution
Here’s how to completely remove Node.js and npm from your Windows system:
1. Uninstall via Control Panel:
- Open the Control Panel on your Windows machine.
- Navigate to Programs and Features (or Add/Remove Programs in older versions).
- Locate Node.js in the list of installed programs.
- Select Node.js and click Uninstall.
- Follow the on-screen instructions to complete the uninstallation process.
2. Clear npm cache:
Even after uninstalling, some leftover files might remain. Let’s clear the npm cache:
- Open a command prompt or terminal window.
- Type the following command and press Enter:
This command forcefully clears the npm cache, removing any remaining packages or data.
3. Manually delete remaining files (Optional):
For a thorough cleanup, you can manually delete the following directories:
- C:\Program Files\nodejs
- C:\Users[Your Username]\AppData\Roaming\npm
- C:\Users[Your Username]\AppData\Roaming\npm-cache
Note: Replace [Your Username] with your actual Windows username.
4. Check environment variables (Optional):
- Right-click on This PC or My Computer and select Properties.
- Go to Advanced system settings and click on Environment Variables.
- Under System variables, look for any entries related to Node.js or npm (e.g., NODE_PATH).
- If found, select the entry and click Delete.
5. Restart your computer:
After completing the above steps, restart your computer to ensure all changes take effect.
Additional Notes:
- If you used a package manager like Chocolatey to install Node.js, you can use the corresponding uninstall command (e.g.,
choco uninstall nodejs). - If you encounter any issues during the uninstallation process, refer to the resources mentioned at the beginning of this guide for further troubleshooting.
By following these steps, you should have successfully removed Node.js and npm from your Windows system. You can now proceed with a fresh installation or explore other development tools.
Code Example
This code snippet demonstrates how to use JavaScript in conjunction with Node Version Manager (nvm) to manage multiple Node.js versions on a system. While not directly uninstalling Node.js, it provides a way to switch between different versions, achieving a similar outcome. The code defines functions to execute shell commands and switch between Node.js versions using nvm. This allows for flexibility in development environments where different projects may require specific Node.js versions.
While the provided instructions are for manual uninstallation steps on Windows, there’s no direct JavaScript code involved in the process. Uninstalling software like Node.js typically involves system-level operations and interacting with the Windows Control Panel or package managers.
However, let’s explore how you might use JavaScript to achieve similar results in a different context:
Scenario: Managing Node.js versions with nvm (Node Version Manager)
nvm is a popular tool for managing multiple Node.js versions on a single machine. Here’s how you can use JavaScript along with nvm to switch between Node.js versions, which indirectly achieves a similar outcome to uninstalling and reinstalling:
const { exec } = require('child_process'); // Function to execute shell commands function runCommand(command) { return new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { reject(error); } else { resolve(stdout.trim()); } }); }); } // Example usage: async function switchNodeVersion(version) { try { // Check if the version is installed const installedVersions = await runCommand('nvm ls'); if (!installedVersions.includes(version)) { console.log(`Installing Node.js version ${version}`); await runCommand(`nvm install ${version}`); } // Use the specified version console.log(`Using Node.js version ${version}`); await runCommand(`nvm use ${version}`); } catch (error) { console.error('Error:', error); } } // Example: Switch to Node.js version 14.18.0 switchNodeVersion('14.18.0');
Explanation:
-
Import
exec: We import theexecfunction from thechild_processmodule to execute shell commands. -
runCommandFunction: This helper function executes a given shell command and returns a Promise that resolves with the command’s output. -
switchNodeVersionFunction:- It takes a Node.js version as input.
- It checks if the version is already installed using
nvm ls. - If not installed, it uses
nvm installto install the version. - Finally, it uses
nvm useto switch to the specified version.
Remember: This example requires having nvm installed and configured on your system.
Limitations:
- This approach doesn’t truly «uninstall» Node.js versions; it manages them within nvm.
- It’s specific to using nvm and may not be applicable to other package managers or environments.
Additional Notes
-
Global Packages: If you’ve installed global packages using npm, you might want to list them before uninstalling using
npm list -g --depth=0. This can help you decide whether to reinstall them later. - Project Dependencies: If you have projects that rely on specific Node.js or npm versions, make sure to note those versions before uninstalling. This will ensure you can recreate the correct environment later.
- Registry Configuration: In some cases, you might have modified the npm registry configuration (e.g., using a private registry). Remember to back up or document these settings if you plan to restore them after reinstallation.
- Third-Party Tools: If you’ve used any third-party tools related to Node.js or npm (e.g., task runners, build tools), consider their compatibility with the new Node.js version you might install.
- Backup Important Data: As with any software uninstallation, it’s a good practice to back up any important data or projects before proceeding. This ensures you don’t lose any critical information during the process.
Summary
| Step | Action | Description |
|---|---|---|
| 1 | Uninstall via Control Panel | Remove Node.js using the Programs and Features (or Add/Remove Programs) option. |
| 2 | Clear npm cache | Use the command npm cache clean --force in a terminal to remove leftover npm data. |
| 3 | Manually delete remaining files (Optional) | Delete directories associated with Node.js and npm, including C:\Program Files\nodejs, C:\Users\[Your Username]\AppData\Roaming\npm, and C:\Users\[Your Username]\AppData\Roaming\npm-cache. |
| 4 | Check environment variables (Optional) | Remove any Node.js or npm related entries from the System variables under Environment Variables. |
| 5 | Restart your computer | Reboot the system to ensure all changes take effect. |
Conclusion
By following the outlined steps, you can effectively remove Node.js and npm from your Windows system. This process involves using the Control Panel, clearing the npm cache, manually deleting remaining files (optional), checking environment variables (optional), and restarting your computer. Remember to consider additional factors such as global packages, project dependencies, registry configurations, third-party tools, and data backups to ensure a smooth uninstallation process. Whether you’re preparing for a fresh installation or exploring alternative development tools, these instructions provide a clear roadmap for successfully uninstalling Node.js and npm from your Windows environment.
References
-
How to completely remove node.js from Windows ? — GeeksforGeeks | A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
-
How to uninstall Node.js? Remove Node.js from your system … | There is no restriction on the type of programming language used for writing server-side code. Some of the popular examples include PHP, Ruby, C#, Python, and Javascript. Out of all these, Javascript is very much popular because of its beginner-friendliness and being able to be used both on the client-side and server-side as well. As
- javascript — How do I completely uninstall Node.js, and reinstall from … | Jun 24, 2012 … First: · To recap, the best way (I’ve found) to completely uninstall node + npm is to do the following: · go to /usr/local/include and delete any …
- How to completely remove node js from Windows | Edureka … | I removed my prior version of node.js (0.8.11), then downloaded and installed the current version, 0.10 … . I’m using a 64-bit version of Windows 7.
-
need help to fix a problem with a corrupted version of node nvm … | I researched a lot on the subject, but I couldn’t find a viable solution to my problem, I’m setting up a development environment by NVM I installed node 8.9.0, I managed to install the NPM package …
- Chocolatey Uninstall NodeJS Windows 8 — Super User | Jan 22, 2015 … 2 Answers 2 · Ensure you are on the more recent version of choco (0.9.9.x series) · choco uninstall npm -dvyaf · choco uninstall nodejs.
-
[BUG] npm install will randomly hang forever and cannot be closed … | Is there an existing issue for this? I have searched the existing issues This issue exists in the latest npm version I am using the latest npm Current Behavior When running npm install it will some…
-
Is there a way to uninstall all node and npm instances from your … | Posted by u/sharemypenguins — 41 votes and 10 comments
- Sharepoint development framework environment setup. Yeoman … | Following the guide https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environmentmade sure of all the prerequisites but as I follow..
Node.js is an essential runtime for JavaScript, and npm (Node Package Manager) is its package manager. However, there are times when you need to completely uninstall and reinstall Node.js and npm, whether due to version conflicts, broken installations, or upgrading to a newer version.
This guide will cover three different methods to uninstall and reinstall Node.js and npm on Windows, macOS, and Linux.
🛠 Method 1: Uninstall & Reinstall Node.js and npm Manually
If you installed Node.js via the official installer or a package manager other than nvm or brew, you’ll need to manually remove it.
🔹 Windows (Manual Uninstallation)
Uninstall Node.js
- Open Control Panel → Programs → Programs and Features.
- Find Node.js in the list.
- Click Uninstall and follow the prompts.
Remove npm Cache & Environment Variables
- Delete the global npm modules:
rd /s /q "%AppData%\npm"
rd /s /q "%AppData%\npm-cache"
Enter fullscreen mode
Exit fullscreen mode
- Remove Node.js from System Environment Variables:
- Press
Win + R, typesysdm.cpl, and hit Enter. - Go to the Advanced tab and click Environment Variables.
- Under System Variables, find
NODE_PATH, select it, and click Delete. - Look for
Path, edit it, and remove any reference to Node.js.
- Press
Verify Node.js Removal
Run the following in PowerShell or CMD:
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
If it returns "command not found", Node.js has been successfully removed.
🔹 macOS (Manual Uninstallation)
Remove Node.js and npm
- Open Terminal and run:
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/include/node
sudo rm -rf /usr/local/lib/node_modules
Enter fullscreen mode
Exit fullscreen mode
- Remove npm cache:
rm -rf ~/.npm
rm -rf ~/.node-gyp
Enter fullscreen mode
Exit fullscreen mode
- If you installed Node.js using the
.pkgfile, you can also remove it via:
sudo rm -rf /usr/local/lib/dtrace/node.d
Enter fullscreen mode
Exit fullscreen mode
Verify Uninstallation
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
If they are no longer recognized, Node.js is fully removed.
🔹 Linux (Manual Uninstallation)
Remove Node.js and npm
- Run the following command:
sudo apt-get remove --purge nodejs npm
Enter fullscreen mode
Exit fullscreen mode
- Clean up global npm packages:
sudo rm -rf /usr/local/lib/node_modules
rm -rf ~/.npm
Enter fullscreen mode
Exit fullscreen mode
Verify Uninstallation
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
🛠 Method 2: Uninstall & Reinstall Node.js via Homebrew (macOS & Linux)
If you installed Node.js via Homebrew, you can easily uninstall and reinstall it.
🔹 Uninstall Node.js using Homebrew
- Open Terminal and run:
brew uninstall node
Enter fullscreen mode
Exit fullscreen mode
- Clean up leftover files:
brew cleanup
Enter fullscreen mode
Exit fullscreen mode
Verify Node.js Removal
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
If Node.js is not found, it has been successfully removed.
🔄 Reinstall Node.js using Homebrew
To reinstall:
brew install node
Enter fullscreen mode
Exit fullscreen mode
After installation, verify:
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
🛠 Method 3: Uninstall & Reinstall Node.js using nvm (Node Version Manager) (My Personal Preference)
If you installed Node.js using nvm, this is the easiest way to manage multiple Node.js versions.
The link to the source code can be found here: nvm-sh/nvm.
🔹 Uninstall Node.js using nvm
- Open Terminal (or PowerShell for Windows).
- Run the following command:
nvm uninstall <version>
Enter fullscreen mode
Exit fullscreen mode
Replace <version> with the installed Node.js version. You can check installed versions with:
nvm ls
Enter fullscreen mode
Exit fullscreen mode
- To completely remove
nvm(optional), delete its directory:
rm -rf ~/.nvm
Enter fullscreen mode
Exit fullscreen mode
🔄 Reinstall Node.js using nvm
- First, make sure
nvmis installed:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Enter fullscreen mode
Exit fullscreen mode
If you are like me and have some problems with the PATH of your nvm installation, run the following command (from the source repository):
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Enter fullscreen mode
Exit fullscreen mode
- Reload your shell configuration:
source ~/.zshrc # For macOS/Linux (zsh users)
source ~/.bashrc # For Linux/macOS (bash users)
Enter fullscreen mode
Exit fullscreen mode
- Install the latest LTS version of Node.js:
nvm install --lts
Enter fullscreen mode
Exit fullscreen mode
- Verify installation:
node -v
npm -v
Enter fullscreen mode
Exit fullscreen mode
🎯 Summary of Uninstallation & Reinstallation Methods
| Method | Windows | macOS | Linux |
|---|---|---|---|
| Manual | Control Panel → Remove Node.js, delete cache |
rm -rf Node files |
apt-get remove |
| Homebrew | ❌ Not available | brew uninstall node |
brew uninstall node |
| nvm | nvm uninstall <version> |
nvm uninstall <version> |
nvm uninstall <version> |
🚀 Which Method Should You Use?
- For beginners: Use the manual method (Control Panel for Windows, Terminal for macOS/Linux).
-
For developers: If you installed Node.js via
brew, use Homebrew for easy management. -
For advanced users: Use
nvmif you frequently switch between Node.js versions easily.
💡 Final Thoughts
Now you know how to completely uninstall and reinstall Node.js and npm using three different methods across Windows, macOS, and Linux. Using nvm is generally the best option for developers as it allows you to switch between different Node.js versions easily.
Let me know if you run into any issues! 🚀
TL;DR
- Manual Method: Control Panel (Windows), Terminal (macOS/Linux).
-
Homebrew:
brew uninstall node(macOS/Linux). -
nvm:
nvm uninstall <version>,nvm install --lts.
