Loading...

How to uninstall Node.js? Remove Node.js from your system completely

How to uninstall Node.js? Remove Node.js from your system completely

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 the server-side runtime environment for Javascript, Node.js lets you build scalable web applications with ease. Despite its popularity among beginning developers, Node.js does not fit every developer’s needs, especially those with different language backgrounds or preferences.

This tutorial will walk you through a step-by-step guide to completely remove Node.js from your computer. Let’s take a deep breath and dive right in!

Prerequisites

Before uninstalling Node.js, it is important that we check if Node.js is properly installed in our system or not. The way we can check that varies by the operating system.

Check if Node.js installed on Windows

  • Using File Explorer:
    1. Go to File Explorer, open This PC -> C:/ drive.
    2. Look for the Nodejs folder in the directory where you installed Nodejs originally.
    3. Some of the other files where we can check for Nodejs or npm files:
      • C:Program Files (x86)Nodejs
      • C:Program FilesNodejs
      • C:Users"user"AppDataRoamingnpm
      • C:Users"user"AppDataRoamingnpm-cache
    4. The folder indicates that Nodejs is installed correctly in your system.

Using CMD:

  • Search for “cmd” in the start menu. Right-click on it and select “Run as administrator”.
  • Or, Press Win+R to open “run”. Enter “cmd” and hit Ctrl+Shift+Enter to open the command prompt as administrator.
  • Write the following command:
node --version
Code language: JavaScript (javascript)

If you get a result like this, it indicates Node is correctly installed on your system:

v16.16.0
Code language: JavaScript (javascript)

Check if Node.js installed on Linux

You can check if Node.js is installed by typing node -v in Terminal. The version number will appear in the terminal. It should look something like this:

v16.16.0
Code language: JavaScript (javascript)

Check if Node.js installed on Mac

  1. Press command+space to open Spotlight Search.
  2. Type “Terminal” and press enter.
  3. Check if Node.js is installed by typing node -v in Terminal.
  4. You should see the version of Node.js that was installed, something like this:
v16.16.0
Code language: JavaScript (javascript)

Uninstalling the Node.js in Windows

There are actually three ways through which we can remove Node.js from our windows system. Let’s have a look at each of them.

Method 1: Uninstalling from Windows Settings

  • Go to Settings by searching it in the start menu.
  • Click on the Apps section.
  • Look for the search box under Apps & Features section, and enter Nodejs there.
  • Select on Nodejs application and click on uninstall.
  • It is recommended that you restart your Windows machine even if you aren’t prompted to do so.
  • Lastly, run cmd as administrator and type:
node --version
Code language: JavaScript (javascript)
  • If you see an output like this: 'node' not recognized as internal or external commandthen Node is successfully uninstalled from your computer.

Method 2: Uninstalling from Windows CMD

  • Search for “cmd” in the start menu. Right-click on it and select “Run as administrator“.
  • Or, Press Win+R to open “run“. Enter “cmd” and hit Ctrl+Shift+Enter to open the command prompt as administrator.
  • Run the following command in your terminal to clear your npm cache:
npm cache clean --force
Code language: JavaScript (javascript)
  • Now, to remove Node.js and npm successfully:
    • Go to the windows control panel.
    • Select Uninstall a program.
    • Right-Click on Nodejs and uninstall.
  • Lastly, run cmd as administrator and type:
node --version
Code language: JavaScript (javascript)
  • If you see an output like this: 'node' not recognized as internal or external commandthen Node is successfully uninstalled from your computer.

Method 3: Uninstalling from Windows Registry

  • Search for “Registry Editor” in the start menu and click on it.
  • Or, Press Win+R to open “run“. Enter “regedit” and hit Enter to open the Windows Registry.
  • A prompt will open asking you to allow the app to make changes. Click Yes.
  • You can either go to the path below or paste it in the path field: ComputerHKEY_LOCAL_MACHINESOFTWARENode.js
  • As a next step, locate the Nodejs directory on the left sidebar. Right-click on it and delete the directory.
  • It is recommended that you restart your Windows machine even if you aren’t prompted to do so.
  • Lastly, run cmd as administrator and type:
node --version
Code language: JavaScript (javascript)
  • If you see an output like this: 'node' not recognized as internal or external commandthen Node is successfully uninstalled from your compute

Uninstalling the Node.js in Ubuntu

We will examine multiple options to uninstall NodeJS in Ubuntu using the three typical commands: uninstall, remove and purge.

Step 1: Locating the Binary Files

You can locate the folder where NodeJS binaries are located and verify if it’s uninstalled as well. This can be done using the which or find command as shown below:

$ which node $ find $(echo $PATH | sed 's/:/ /g') -name "node"
Code language: JavaScript (javascript)
$ find / -name "node"
Code language: JavaScript (javascript)

You should see an output similar to this if the node is installed:

/user/bin/node /user/bin/node
Code language: JavaScript (javascript)
/user/bin/node /user/share/doc/node /user/share/code/resources/app/extensions/emmet/dist/node /user/share/code/resources/app/extensions/css-language-features/server/dist/node /user/share/code/resources/app/extensions/css-language-features/client/dist/node /user/share/code/resources/app/extensions/ms-vscode.js-debug/src/targets/node /user/share/code/resources/app/extensions/html-language-features/server/dist/node /user/share/code/resources/app/extensions/html-language-features/client/dist/node /user/share/code/resources/app/extensions/json-language-features/server/dist/node /user/share/code/resources/app/extensions/json-language-features/client/dist/node /user/share/code/resources/app/out/vs/workbench/api/node /user/share/code/resources/app/out/vs/workbench/contrib/debug/node /user/share/code/resources/app/out/vs/workbench/contrib/externalTerminal/node /user/share/code/resources/app/out/vs/base/node /user/share/code/resources/app/out/vs/platform/files/node /user/share/code/resources/app/out/vs/platform/environment/node /user/share/code/resources/app/out/vs/platform/terminal/node j/user/share/code/resources/app/out/vs/code/node /user/include/node
Code language: JavaScript (javascript)

Step 2: Uninstalling NodeJS

Now, there are different ways of removing Nodejs from the system. Let’s look at some of the options below:

Method 1: Removing the binary paths

We can discard Nodejs by manually deleting the binaries we located in the previous step, although this method is less recommended than others.

$ sudo rm /user/bin/node
Code language: JavaScript (javascript)

Method 2: Use the apt or apt-get command to Uninstall

The most commonly used commands in Ubuntu to uninstall NodeJS are apt and apt-get.

$ sudo apt-get remove nodejs
Code language: JavaScript (javascript)

The above command only removes the package. In order to remove all the node-related packages as well, see the methods in step 4.

Method 3: Uninstalling a Particular version of NodeJS

Suppose you want to uninstall only a specific version of NodeJS. You can use the below command to remove that version only. Eg:

$ nvm uninstall 16.16.0
Code language: JavaScript (javascript)

You should see an output like this:

Uninstalled node v16.16.0
Code language: JavaScript (javascript)

Step 3: Removing NodeJS info from the Source Lists

After removing NodeJS, check to see if there is any NodeJS data present in the /etc/apt/sources.list.d directory:

$ ls /etc/apt/sources.list.d
Code language: JavaScript (javascript)

You should see folders named nodesource.list and nodesource.list.distUpgrade. If not present then your NodeJS information is removed from the sources list. Otherwise, Use the below command to remove them:

$ rm -rf nodesource.list nodesource.list.distUpgrade
Code language: JavaScript (javascript)

Last but not the least, make sure to update the Ubuntu repositories.

$ sudo apt-get update
Code language: JavaScript (javascript)

Step 4: Clearing the Cache

NodeJS can sometimes leave traces of some packages and modules after uninstalling. You can use any of the following methods to remove all the node-related packages as well as the configuration files.

Method 1: Using the purge command

The purge command helps us remove all these packages and files. Use any of the two commands below:

$ sudo apt-get purge nodejs
Code language: JavaScript (javascript)

or

$ sudo apt-get purge – auto-remove nodejs
Code language: JavaScript (javascript)

Method 2: Removing npm manually

You can manually remove the hidden npm directories and other related files using the below commands:

$ ls -la $ rm -rf .npm
Code language: JavaScript (javascript)

Step 5: Remove Unused Files

The last step is to run the following command to get rid of unused files and free up the space on your computer.

$ sudo apt-get autoremove
Code language: JavaScript (javascript)

Uninstalling the Node.js on Mac

Now, let’s look at some of the ways to uninstall Node.js from MacOS as well.

Method 1: Uninstalling using homebrew

  • Click on the search icon in the menu bar or press command + space to launch the spotlight.
  • Type terminal and hit Return.
  • Run this command to uninstall all versions of Node from your mac.
# brew uninstall --force node
Code language: JavaScript (javascript)
  • Once that’s done, type the following command to remove unused folders and dependencies.
# brew cleanup
Code language: JavaScript (javascript)

Method 2: Uninstalling using NVM

  • Click on the search icon in the menu bar or press command + space to launch the spotlight.
  • Type terminal and hit Return.
  • To uninstall the node with the help of nvm, type the following command, replacing <version> with the current version of your node installed. Eg: v16.16.0.
# nvm uninstall <version>
Code language: JavaScript (javascript)

Method 3: Uninstalling using terminal

  • Click on the search icon in the menu bar or press command + space to launch the spotlight.
  • Type terminal and hit Return.
  • Once the terminal is opened, enter the given below command:
# sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
Code language: JavaScript (javascript)
  • The above command will not remove all of the packages. To delete every global package you have installed using npm, run the below command:
# rm –rf ~/.npm
Code language: JavaScript (javascript)

Method 4: Uninstalling Node Manually

  • From the Dock, select the Go menu and then Folder from the Finder icon.
  • In the text box, paste the directory path: /usr/local/lib
  • Then move any files that have the name ‘node’ to the Trash.
  • Paste each of the following paths into the text box in Go to Folder and drag the files with the name ‘node’ to the Trash.
/usr/local/bin /usr/local/include /usr/local/share/man/man1/ /usr/local/lib/dtrace/ /opt/local/bin/ /opt/local/include/ /opt/local/include/ /usr/local/share/doc/ /usr/local/share/systemtap/tapset/
Code language: JavaScript (javascript)
  • Drag the following files in the Home folder to the Trash: .npm, .node-gyp, .nodereplhistory.
  • Lastly, empty the Trash.

Conclusion

That was pretty much it! Hopefully, you can now successfully uninstall NodeJS from your computer.

If you ever feel lost and want help understanding where to start your coding journey then go check out Codedamn. There are amazing courses and blogs for web development and other coding concepts. Remember to practice coding on a daily basis. You can play around with your code on Codedamn’s online compiler as well

Let us know in the comments if you have any suggestions or queries. Finally, If you are interested in my content and would like to connect, then you can find me on Linkedin or Twitter.

Sharing is caring

Did you like what Indrakant wrote? Thank them for their work by sharing it on social media.

0/20000

No comments so far