For Ubuntu 12.04:

sudo apt-get remove nodejs

This will uninstall nodejs as well as npm.

Answer from Manoj Gupta on Stack Overflow
Discussions

Uninstall node js
Hi, I need to uninstall node js as it was installed incorrectly. Does anyone have a simple way of doing this in Ubuntu based Linux (Linux lite). I tried manually deleting the node modules but I have to go through each module individually to do this as they are write protected. More on freecodecamp.org
🌐 freecodecamp.org
1
0
May 22, 2018
What's the best way to remove Node.js, NPM, and all related packages from Ubuntu?
Hey everyone! I’m trying to do a clean sweep of Node.js and NPM from my Ubuntu machine. I originally installed Node.js using sudo apt-get install node, but now I want to get rid of everything. I’m talking about: Node.js itself NPM All the global packages I’ve installed (like @vue/cli) ... More on community.latenode.com
🌐 community.latenode.com
0
April 8, 2025
How do I completely remove Node and NPM?
To be honest, it looks like it might just be an issue with your package.json file not actually being perfectly valid JSON. Did you modify it by hand at all? I'd throw it in a JSON validator online real quick before the hassle of removing and adding node/npm. More on reddit.com
🌐 r/Ubuntu
9
3
January 6, 2019
how to uninstall

Do:

sudo npm uninstall -f npm
sudo dnf remove nodejs -y
More on reddit.com
🌐 r/Fedora
5
2
June 4, 2018
🌐
ByteXD
bytexd.com › how-to-uninstall-nodejs-in-ubuntu
How to Uninstall NodeJS in Ubuntu 22.04 - ByteXD
July 31, 2022 - The confusion worsens when you are unsure whether to use the uninstall, remove, or purge commands. This tutorial simplifies NodeJS uninstallation by explaining the workings of package managers, installation directories and the most suitable commands to apply.
Top answer
1 of 5
137

As seen from the output of:

sudo apt-get purge nodejs

it is only removing node related packages i.e. relevant packages, nothing more.

On the other hand, when you do:

sudo apt-get purge --auto-remove nodejs

it is essentially doing:

sudo apt-get purge nodejs
sudo apt-get autoremove

and the removal of the gyp, linux-headers-4.4.0-18-generic etc packages are actually triggered by autoremove as they were installed as dependencies and no longer needed by any installed package, presumably because the main package has been removed.

So it is perfectly fine in this context to run:

sudo apt-get purge --auto-remove nodejs

If you are too paranoid, you can do it in two steps: first purge nodejs:

sudo apt-get purge nodejs

and then remove the orphan dependencies (till now, if any):

sudo apt-get autoremove
2 of 5
26

To remove node js, npm and node_modules from Ubuntu, you need to remove containers also which are at different locations in Ubuntu. These could be as:

/usr/local/bin/npm, /usr/local/share/man/man1/node, /usr/local/lib/dtrace/node.d, ~/.npm ~/.node-gyp, /opt/local/bin/node, opt/local/include/node, /opt/local/lib/node_modules

I have posted the procedure to remove NodeJS on my blog: AMCOS IT Support For Windows and Linux: To completely uninstall node js from Ubuntu.

  1. First of all you need to run the following command from command terminal as sudo.

    sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
    
  2. Remove node or node_modules directories from /usr/local/lib with the help of following command.

    sudo rm -rf /usr/local/lib/node*
    
  3. Remove node or node_modules directories from /usr/local/include with the help of following command.

    sudo rm -rf /usr/local/include/node*
    
  4. Remove any node file or dir from /usr/local/bin with the help of following command.

    sudo rm -rf /usr/local/bin/node*
    
  5. Go to home directory and remove any node or node_modules directory, if exists.

🌐
Codedamn
codedamn.com › news › node.js
How to uninstall Node.js? Remove Node.js from your system completely
June 2, 2023 - 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. ... We will examine multiple options to uninstall NodeJS in Ubuntu using the three typical commands: uninstall, remove and purge.
🌐
CodeForGeek
codeforgeek.com › home › different ways to uninstall node.js from windows: an easy guide
Different Ways to Uninstall Node.js from Windows: An Easy Guide | CodeForGeek
May 27, 2024 - The “nodejs” directory containing the Node modules directory should now be gone. No matter which method you use, you may be asked to restart your Windows machine. If not, it is still recommended that you do so. Sometimes, changes may take time to be reflected. The fastest way to uninstall Node is by using the command line:
🌐
Edureka Community
edureka.co › home › community › categories › web development › node-js › how can i completely uninstall nodejs npm and...
How can I completely uninstall nodejs npm and node in Ubuntu | Edureka Community
May 14, 2022 - I installed it using: sudo apt-get install node. My question is that how can I remove npm along ... , packages, and any other files installed by npm.
Find elsewhere
🌐
Linux Hint
linuxhint.com › remove-nodejs-windows
How to Remove Node.js From Windows
February 27, 2023 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Bitcoden
bitcoden.com › answers › uninstall-nodejs-using-linux-command-line
HugeDomains.com
Questions?+1-303-893-0552 · Captcha security check · Dedicated to customer care · 30-day money back guarantee · Talk to a domain expert: +1-303-893-0552
🌐
Hungred Blog
hungred.com › how-to › completely-removing-nodejs-npm
Completely removing Node.js and Npm - Hungred Dot Com
June 20, 2014 - git clone git://github.com/ry/node.git cd node ./configure make sudo make install · Inside the source code, instead of hitting 'make' and 'make install', do the following ... This instruction will uninstall whatever the source has installed into your machine.
🌐
npm
docs.npmjs.com › misc › removing-npm.html
Npmjs
Documentation for the npm registry, website, and command-line interface
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-node-js-on-ubuntu-18-04
How To Install Node.js on Ubuntu 18.04 | DigitalOcean
December 29, 2021 - You’ve successfully installed Node by using the Node Version Manager, nvm, to install and manage various versions of Node. You can uninstall Node.js using apt or nvm, depending on the version you want to target. To remove the default repository version, you will use apt at the system level.
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › uninstall-node-js-using-linux-command-line
Uninstall Node.JS Using Linux Command Line - GeeksforGeeks
October 17, 2024 - nvm (Node Version Manager) for managing multiple versions of Node.js. Manual installation from binary files. ... This will uninstall nodejs from the system.
🌐
Groove Technology
groovetechnology.com › home › blog › technologies › how to remove nodejs from ubuntu? a comprehensive guide
A Complete Guide To Removing NodeJS From Ubuntu
September 26, 2024 - Learn how to completely remove NodeJS from Ubuntu with this step-by-step guide, ensuring a clean uninstallation process.
🌐
Latenode
community.latenode.com › other questions › npm
What's the best way to remove Node.js, NPM, and all related packages from Ubuntu? - NPM - Latenode Official Community
April 8, 2025 - Hey everyone! I’m trying to do a clean sweep of Node.js and NPM from my Ubuntu machine. I originally installed Node.js using sudo apt-get install node, but now I want to get rid of everything. I’m talking about: Node.js itself NPM All the global packages I’ve installed (like @vue/cli) ...
🌐
Softsuave
softsuave.com › home › how to uninstall node js: best practices for a clean uninstall
How to Uninstall Node js: Best Practices for a Clean ...
May 13, 2025 - 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.
🌐
Rotadev
rotadev.com › how-can-i-completely-uninstall-nodejs-npm-and-node-in-ubuntu-closed-dev
How can I completely uninstall nodejs, npm and node in Ubuntu [closed] – Dev – RotaDEV.com
sudo rm -rf /usr/local/bin/npm sudo rm -rf /usr/local/share/man/man1/node* sudo rm -rf /usr/local/lib/dtrace/node.d rm -rf ~/.npm rm -rf ~/.node-gyp sudo rm -rf /opt/local/bin/node sudo rm -rf /opt/local/include/node sudo rm -rf /opt/local/lib/node_modules sudo rm -rf /usr/local/lib/node* sudo rm -rf /usr/local/include/node* sudo rm -rf /usr/local/bin/node* I have posted a step by step guide with commands on my blog: AMCOS IT Support For Windows and Linux: To completely uninstall node js from Ubuntu.