For Ubuntu 12.04:

sudo apt-get remove nodejs

This will uninstall nodejs as well as npm.

Answer from Manoj Gupta on Stack Overflow
🌐
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.
People also ask

How to uninstall Node, npm, and nvm?
You can completely remove Node.js, npm, and nvm by first using commands like nvm uninstall or nvm remove. Then, delete the remaining Node.js directories and npm cache to finish the Node.js uninstall process.
🌐
visionx.io
visionx.io › home › blog › how to uninstall node.js on different operating systems?
How to Uninstall Node.js on Different Operating Systems? - VisionX
How to uninstall Node.js in Windows Command Prompt?
While there isn’t a direct uninstall Node.js on Windows command, you can use Command Prompt to remove Node.js by first running npm uninstall -g for global modules, then manually deleting the Node.js installation folder and npm directories.
🌐
visionx.io
visionx.io › home › blog › how to uninstall node.js on different operating systems?
How to Uninstall Node.js on Different Operating Systems? - VisionX
How to uninstall npm in Windows?
The npm can be removed during the process of uninstalling Node.js on Windows. After using Control Panel or Command Prompt to uninstall Node, delete the npm and npm-cache folders from AppDataRoaming.
🌐
visionx.io
visionx.io › home › blog › how to uninstall node.js on different operating systems?
How to Uninstall Node.js on Different Operating Systems? - VisionX
🌐
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.
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.

🌐
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.
🌐
AlmaBetter
almabetter.com › bytes › articles › uninstall-node-js-ubuntu
How to Uninstall Node JS in Ubuntu? (Step by Step Guide)
October 17, 2023 - Check out the Node JS tutorial! How to uninstall node in Ubuntu - it relies on the APT (Advanced Package Tool) package manager for handling software installations. To uninstall Node js Ubuntu, you'll start by removing the Node.js package.
Find elsewhere
🌐
Medium
medium.com › @scriptsar.info › step-by-step-guide-how-to-install-uninstall-node-js-on-linux-cec1b884a063
Step-by-step guide how to install & uninstall Node.js on Linux: | by scriptsar | Medium
October 9, 2023 - Step-by-step guide how to install & uninstall Node.js on Linux: METHOD 1 Installing and Uninstalling Node.js on Linux (Using the Official Ubuntu Repository) Step 1: Update Your System Before …
🌐
VisionX
visionx.io › home › blog › how to uninstall node.js on different operating systems?
How to Uninstall Node.js on Different Operating Systems? - VisionX
September 4, 2025 - Uninstalling Node.js on Linux systems can be approached through the package manager provided by your Linux distribution or via manual removal if Node.js was installed from the source.
🌐
GitHub
gist.github.com › musale › c362d986b78a2be14af6ce719f7cb9e1
Remove and re-install node on arch linux · GitHub
Remove and re-install node on arch linux · Raw · remove.sh · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
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.
🌐
Scaler
scaler.com › topics › uninstall-node-js
How to uninstall Node.js? - Scaler Topics
September 22, 2023 - It provides a convenient way to uninstall Node.js and related packages. Alternatively, manual removal involves locating and deleting specific directories and files associated with Node.js. Ubuntu (Linux) : On Ubuntu, a Linux distribution, Node.js can be uninstalled using the package manager, ...
🌐
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) ...
🌐
Web Hosting Geeks
webhostinggeeks.com › home › ubuntu › how to uninstall node.js and npm on ubuntu
How to Uninstall Node.js and npm on Ubuntu | Linux Tutorials for Beginners
October 17, 2023 - In this guide, we’ll walk you through the steps to completely remove Node.js and npm from your Ubuntu machine. Let’s get started. Before uninstalling Node.js and npm, it’s essential to determine how you initially installed them.
🌐
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.
🌐
Quora
quora.com › How-do-I-completely-uninstall-NodeJs-and-re-install-the-latest-version-of-NodeJs
How to completely uninstall NodeJs and re-install the latest version of NodeJs - Quora
Answer (1 of 8): EDIT 1 : On Linux : - Install the node version manager. [code]curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash [/code] * check if there is an installed node version : [code]node --version [/code] * if there exists a node version : [code]#...
🌐
iO Flood
ioflood.com › blog › uninstall-npm
How to Uninstall Node.js and npm | Step-by-Step Guide
March 26, 2024 - 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. 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. After uninstalling Node.js and npm using the basic steps, it’s time to ensure no residual files are left lurking in your system.