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.
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!
Here at IOFLOOD, as part of our server management duties, we often encounter the need to streamline software configurations and dependencies. Due to this, we have designed a guide on how to uninstall Node.js and npm, two commonly used tools in our server environments. By providing step-by-step instructions, we aim to simplify the process for our customers, enabling them to efficiently remove these components when necessary, whether for cleanup or troubleshooting purposes.
Uninstalling Node.js and npm is about more than just cleaning; it’s about setting the stage for new growth and possibilities. To this end, this guide will walk you through the steps to uninstall Node.js and npm effectively, ensuring a clean slate for your future projects. We’ll cover everything from the basic commands to more nuanced steps for a thorough uninstallation.
So let’s get started with uninstalling npm!
TL;DR: How Do I Uninstall Node.js and npm?
Uninstalling Node.js and npm involves removing the Node.js software and deleting the npm directories. For Linux/macOS users, you can quickly do this with a command such as
sudo apt-get remove nodejs npm
orsudo rm -rf /usr/local/bin/npm
in the terminal. And for Windows users, the process involves using the ‘Add or Remove Programs’ feature.
Here’s a quick command for Linux/macOS users:
sudo apt-get remove nodejs npm
And for Windows users, navigate to ‘Add or Remove Programs’ and uninstall Node.js.
This TL;DR section provides a snapshot for quickly uninstalling Node.js and npm, but there’s more to it, especially if you want to ensure a clean and complete removal. Continue reading for detailed instructions, platform-specific tips, and troubleshooting advice.
Table of Contents
- Uninstall Node.js and npm: The Basics
- Deep Clean: Removing Residual Files
- Alternative Uninstall Methods
- Troubleshooting Uninstallation Issues
- Understanding Node.js and npm
- Next Steps After Uninstallation
- Wrapping Up: Uninstalling Node.js and npm
Uninstall Node.js and npm: The Basics
Embarking on the journey to uninstall Node.js and npm from your system? Whether you’re on Windows, macOS, or Linux, this beginner-friendly guide has got you covered. Let’s dive into the step-by-step instructions to ensure you can remove Node.js and npm without leaving any traces behind.
Windows: Uninstall Node.js and npm
For Windows users, the process is straightforward thanks to the ‘Add or Remove Programs’ feature.
1. Open the Start Menu and search for ‘Add or Remove Programs’.
2. Scroll to find Node.js in the list and select ‘Uninstall’.
After uninstalling Node.js, it’s crucial to also remove any residual npm packages and cache to ensure a complete cleanup.
rd /s /q %UserProfile%\AppData\Roaming
pm
rd /s /q %UserProfile%\AppData\Roaming
pm-cache
# Output:
# This command does not produce an output but deletes the npm and npm-cache directories.
macOS and Linux: Uninstall Node.js and npm
On macOS and Linux, the process involves using the terminal.
For macOS users:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
For Linux users, the command might vary slightly based on the distribution. A common command is:
sudo apt-get purge nodejs npm
# Output:
# 'Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following packages will be REMOVED:
# nodejs npm
# 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
# After this operation, XX MB disk space will be freed.'
These commands remove the Node.js and npm installations, along with their directories. It’s important to also consider clearing the npm cache and any global packages installed. For a thorough cleanup, ensure you also delete the global npm package directory, often found in /usr/local/lib/node_modules
for macOS and Linux users.
Clearing npm Cache
Regardless of your operating system, clearing the npm cache is a crucial step in completely removing npm from your system.
npm cache clean --force
# Output:
# 'Cache cleaned.'
This command forcefully clears the npm cache, removing any stored data from your system and ensuring that no remnants of npm remain. It’s an essential step for a fresh start or before installing a different version of Node.js and npm.
Deep Clean: Removing Residual Files
After uninstalling Node.js and npm using the basic steps, it’s time to ensure no residual files are left lurking in your system. These leftovers can take up unnecessary space or cause conflicts with future installations. Let’s explore how to locate and remove these remnants for a truly clean system.
Locate and Delete npm Cache and Global Packages
Even after uninstallation, npm cache and global packages might still reside on your computer. Here’s how you can find and remove them, ensuring a comprehensive cleanup.
Finding and Clearing npm Cache
The npm cache is a repository for the packages that npm accesses and stores temporarily. Over time, this cache can grow significantly. Here’s how to find and remove it:
npm cache verify
# Output:
# Cache verified: X items, Y MB
This command helps you verify the current state of the cache, including its size and the number of cached items. After verifying, you can proceed to clear it:
npm cache clean --force
# Output:
# Cache cleaned.
The --force
flag is necessary because, by default, npm prevents cache cleaning to avoid potential data loss. This command removes all cached data, ensuring that no outdated or unnecessary package data remains.
Removing Global npm Packages
Global npm packages are installed system-wide and can remain after Node.js and npm are uninstalled. To list global npm packages:
npm list -g --depth=0
# Output:
# /usr/local/lib
# ├── package-name@version
This command lists all global packages installed on your system. To remove them, you can use the npm uninstall -g
command followed by the package name. Here’s an example:
npm uninstall -g package-name
# Output:
# removed 1 package in Xs
Removing global packages ensures that no unnecessary packages linger, which could interfere with future installations or take up valuable disk space.
Manual Cleanup of Residual Directories
After using commands to remove npm and Node.js, some directories might still exist. Manually checking and removing these directories is crucial for a complete cleanup. Common locations include /usr/local/lib/node_modules
for Node.js and /usr/local/bin
for npm binaries. Use your system’s file explorer or terminal to navigate and delete these directories.
By following these advanced steps, you ensure a thorough removal of Node.js and npm from your system, paving the way for a clean environment for future projects.
Alternative Uninstall Methods
When the standard uninstallation commands don’t cut it, or you’re looking for a smoother, more automated process, alternative methods come into play. These approaches can vary from using third-party uninstaller tools to leveraging package managers like Homebrew on macOS. Let’s dive into these methods, weighing their benefits and potential drawbacks.
Third-Party Uninstaller Tools
Third-party uninstaller tools can provide a more comprehensive cleanup than the built-in uninstallation process. These tools often scan for residual files and directories that manual or command-line uninstallations might miss.
However, it’s essential to choose a reputable uninstaller to avoid introducing malware or other unwanted software onto your system. Research and select a tool with positive reviews and a strong track record.
Using Homebrew on macOS
For macOS users, Homebrew is a beloved package manager that can also manage uninstallations. If you installed Node.js and npm via Homebrew, uninstalling is straightforward with a single command:
brew uninstall node
# Output:
# Uninstalling /usr/local/Cellar/node/XX.X.X... (X,XXX files, XX.XMB)
# node XX.X.X has been uninstalled!
This command removes Node.js and npm, including all the files and directories associated with the installation. The output confirms the successful uninstallation, listing the number of files and the total space reclaimed.
Pros and Cons
Pros:
– Third-party tools and package managers like Homebrew can automate the uninstallation process, making it more thorough and less time-consuming.
– They can help remove residual files and directories, ensuring a cleaner system.
Cons:
– Third-party tools carry a risk of malware, especially if not carefully selected.
– These methods may require additional software installations, which might not be ideal for users seeking minimalism.
In summary, while alternative uninstallation methods can offer a more automated and comprehensive cleanup, they come with their own set of considerations. Whether you opt for a third-party tool or a package manager like Homebrew, ensure you’re using reputable software to maintain your system’s integrity and security.
Troubleshooting Uninstallation Issues
Navigating the uninstallation of Node.js and npm can sometimes lead you into murky waters. Let’s shine a light on common issues you might encounter and how to address them, ensuring a smooth and complete removal process.
Permission Errors During Uninstallation
One of the most common hurdles is encountering permission errors, especially when using commands that require administrative or superuser privileges.
If you’re on Linux or macOS and face permission issues, prefixing your command with sudo
can grant the necessary permissions:
sudo npm uninstall -g npm
# Output:
# up to date in 0.05s
# fixed 0 of 0 vulnerabilities
This command attempts to uninstall npm globally with superuser permissions. The output indicates that the operation was successful, with no vulnerabilities remaining.
Ensuring Complete Uninstallation
After running the standard uninstallation commands, it’s crucial to verify that Node.js and npm are indeed fully removed from your system. A quick way to check is to use the version check commands:
node -v
npm -v
# Output:
# bash: node: command not found
# bash: npm: command not found
The expected output should indicate that both commands are not found, signifying that Node.js and npm are no longer installed on your system.
Incomplete Uninstallation Fixes
If you still find traces of Node.js or npm after uninstallation, revisiting the manual removal of residual files and directories is advisable. Ensure you’ve deleted the npm cache, global npm packages, and any Node.js binaries lingering in system paths.
Verification Steps
Finally, to doubly ensure that Node.js and npm have been eradicated:
- Restart your computer to clear any system caches.
- Open your terminal and rerun the version check commands.
By addressing these common issues and considerations, you can navigate the uninstallation process more confidently, ensuring that Node.js and npm are thoroughly removed from your system. This paves the way for a clean environment, free from potential conflicts or errors in future installations.
Understanding Node.js and npm
Before diving into the specifics of uninstallation, it’s crucial to grasp what Node.js and npm are and the roles they play in development environments. This foundational knowledge will illuminate why and when their uninstallation becomes necessary.
What is Node.js?
Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript on the server-side. It’s designed to build scalable network applications, making it a staple in web development, especially for real-time applications.
The Role of npm
npm, which stands for Node Package Manager, is the default package manager for Node.js. It facilitates the management of packages (libraries, tools, and frameworks) that enhance the functionality of Node.js applications. npm simplifies the process of sharing, updating, and using code across projects.
Why Uninstall?
Uninstallation of Node.js and npm might be necessary for several reasons:
- Upgrading to a Newer Version: To ensure compatibility or leverage new features, developers might need to uninstall an older version before installing a newer one.
- Switching Development Environments: Moving to a different development environment or runtime might require the removal of Node.js and npm.
- Resolving Conflicts: Sometimes, conflicting versions of Node.js or npm can cause issues in projects. Uninstalling can help reset the environment.
- System Cleanup: Regular maintenance or the desire to declutter the development environment might lead to uninstallation.
Understanding these components and their significance in the development process highlights the importance of knowing how to uninstall them properly. Whether it’s for an upgrade, a clean slate, or resolving conflicts, the ability to uninstall Node.js and npm effectively is a valuable skill for any developer.
Next Steps After Uninstallation
With Node.js and npm successfully uninstalled, you’ve set the stage for new beginnings. Whether you’re aiming for a cleaner development environment, exploring alternative JavaScript runtimes, or planning to reinstall Node.js for a fresh start, there’s a path forward. Let’s explore some actionable next steps and resources to guide you on your journey.
Exploring Alternative JavaScript Runtimes
If you’re curious about what lies beyond Node.js, several alternative JavaScript runtimes offer unique features and capabilities. For instance, Deno, created by the original creator of Node.js, focuses on security and supports TypeScript out of the box. Another option is Electron, perfect for building cross-platform desktop apps with web technologies.
Reinstalling Node.js: A Fresh Start
Reinstalling Node.js can be the next step for many, especially if the uninstallation was part of an upgrade process. When reinstalling, consider using nvm (Node Version Manager) to manage multiple Node.js versions. This tool simplifies switching between versions and managing dependencies.
nvm install node
# Output:
# Downloading and installing node vXX.X.X...
# Now using node vXX.X.X (npm vX.X.X)
This command installs the latest version of Node.js, allowing you to start anew with the latest features and security updates. nvm also makes it easy to switch back if you need an older version for specific projects.
Cleaning Up the Development Environment
After uninstallation and before moving forward, take a moment to clean up your development environment. This can involve organizing project directories, reviewing installed software, and ensuring your development tools are up to date. A clean environment reduces clutter and can improve overall productivity.
Further Resources for Node.js and npm Mastery
To deepen your knowledge and skills, here are three carefully selected resources:
- Node.js Official Website – The best place to start for official documentation, news, and resources.
-
npm Documentation – Guides and documentation to master npm, from basic usage to advanced package management.
-
The Node.js Handbook – A free, comprehensive guide covering everything from Node.js basics to advanced concepts.
These resources provide a wealth of information for both beginners and experienced developers, offering guides, tutorials, and insights into best practices for working with Node.js and npm.
Wrapping Up: Uninstalling Node.js and npm
In this comprehensive guide, we’ve navigated the process of uninstalling Node.js and npm, ensuring your development environment remains clean and up-to-date. The journey to maintain a tidy workspace is akin to gardening; it requires regular attention and care to foster growth and innovation.
We began with the basics, providing step-by-step instructions for Windows, macOS, and Linux users. We explored how to remove Node.js and npm using simple commands and delved into the importance of also clearing out global npm packages and cache to avoid future conflicts.
Moving to more advanced techniques, we discussed manually removing residual files and directories that might linger after a standard uninstallation. This ensures a thorough cleanup, leaving no trace of Node.js and npm behind.
For those seeking alternative methods, we explored the use of third-party uninstaller tools and package managers like Homebrew for macOS users. Each approach offers its pros and cons, from automated processes to potential risks associated with third-party software.
Method | Pros | Cons |
---|---|---|
Standard Commands | Direct, usually effective | May leave residuals |
Third-Party Tools | Comprehensive cleanup | Risk of malware |
Package Managers | Automated, convenient | May require additional setup |
As we conclude this guide, remember that uninstalling Node.js and npm is just the beginning. Whether you’re upgrading to a newer version, switching development environments, or simply decluttering, a clean slate opens up a world of possibilities for your projects.
We hope this guide has equipped you with the knowledge and tools needed for a successful uninstallation. Continue exploring, learning, and growing in your development journey. Happy coding!
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
.pkg
file, 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
nvm
is 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
nvm
if 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
.
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.
How to Uninstall Node in 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.
Uninstall Node.js Ubuntu
Step 1: Uninstall Node.js and npm via APT
If you installed Node.js using Ubuntu’s package manager:
Command:
sudo apt-get purge nodejs npm
sudo apt-get autoremove
Explanation:
This command removes Node.js, npm, and their associated configuration files. The autoremove command cleans up any unused dependencies.
Step 2: Remove Residual Files and Directories
Command:
sudo rm -rf ~/.npm ~/.node-gyp
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/bin/node /usr/local/bin/npm
Explanation:
These commands delete user-specific and system-wide residual files and directories related to Node.js and npm.
Step 3: Remove Node.js APT Source Entries
Command:
sudo rm /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
Explanation:
This removes the NodeSource repository entry from APT sources and updates the package list.
Step 4: Uninstall Node.js Installed via Snap
Command:
sudo snap remove node
Explanation:
If Node.js was installed using Snap, this command will remove it.
Step 5: Uninstall Node.js Installed via NVM
Command:
nvm ls
nvm uninstall <version>
rm -rf ~/.nvm
Explanation:
These commands list installed Node.js versions via NVM, uninstall a specific version, and remove NVM itself.
Step 6: Verify Uninstallation
Command:
node -v
npm -v
Explanation:
Running these commands should result in errors indicating that Node.js and npm are no longer installed.
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!