sudo apt-get remove nodejs
sudo apt-get remove npm

Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do a

sudo apt-get update

Check for any .npm or .node folder in your home folder and delete those.

If you type

which node

you can see the location of the node. Try which nodejs and which npm too.

I would recommend installing node using Node Version Manager(NVM). That saved a lot of headache for me. You can install nodejs and npm without sudo using nvm.

Answer from Raja on Stack Overflow
Discussions

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 9, 2019
How to uninstall NodeJS v0.12? (no longer listed in package center)
Haven't run into this problem myself, but is there maybe an underlying package installed that hasn't been updated that installed it as a dependency? (No idea if this is even possible in DSM -- just something that happens with package managers sometimes) More on reddit.com
🌐 r/synology
2
2
June 1, 2022
How do I install nodejs from the downloaded file on Ubuntu?

I'm not sure what file you have, but you might either want to add the ppa to get more current versions via apt or use nvm to install and switch between multiple versions. Instructions for both: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

More on reddit.com
🌐 r/node
6
0
August 14, 2017
People also ask

Why might I need to uninstall Node.js and npm?
There are several reasons, including the need to install a different version, resolving conflicts, or freeing up system resources.
🌐
webhostinggeeks.com
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 ...
Is it safe to uninstall Node.js and npm?
Yes, but ensure you have backups of any critical data or applications that depend on them.
🌐
webhostinggeeks.com
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 ...
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
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.

🌐
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 - The key is being prepared by backing up existing projects, noting global packages for later reinstallation, and understanding what directories require deletion. Each platform has its own quirks, utilizing the Control Panel or Command Prompt for uninstalling Node.js on Windows, Homebrew or manual deletion for uninstalling Node on Mac, and package managers or source uninstalls for uninstalling Node on Linux or Ubuntu.
🌐
Codedamn
codedamn.com › news › node.js
How to uninstall Node.js? Remove Node.js from your system completely
June 2, 2023 - 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.
🌐
JanBask Training
janbasktraining.com › community › web-development › how-can-i-uninstall-or-remove-node-js1
How can I uninstall or remove node js? | JanBask Training Community
January 4, 2024 - Manual uninstallation: If you don’t install node.js from homebrew then you can delete it manually by using the following command: Sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} Sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules For Linus(ubuntu): Terminals: open the terminal files ·
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › install-uninstall-nodejs-ubuntu
How to Install/Uninstall NodeJS on Ubuntu 18.04 | DigitalOcean
August 3, 2022 - node nodeapp.js · Sample Output This will display the content of the application on port 3000. Ensure the port is allowed on the firewall of your system. ufw allow 3000/tcp ufw reload · Now open your browser and browse the server’s address as shown · https://server-ip:3000 · If you wish to uninstall NodeJS from your Ubuntu system, run the command below.
🌐
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 - Open the “Ubuntu Software” application. In the search bar at the top right, type “node.” · Locate the “Node.js” package in the search results. Click on “Node.js” to view more details.
🌐
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.
🌐
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.
🌐
Uptimia
uptimia.com › home › questions › how to completely uninstall node.js and npm in ubuntu?
How To Completely Uninstall Node.js And NPM In Ubuntu?
August 22, 2024 - Learn how to fully remove Node.js and NPM from your Ubuntu system with step-by-step instructions for a clean uninstallation process.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-node-js-on-ubuntu-20-04
How to Install Node.js on Ubuntu | DigitalOcean
May 2, 2025 - # Uninstall Node.js using apt sudo apt purge nodejs # Uninstall Node.js using NVM nvm uninstall node · No, Ubuntu 20.04 does not come with Node.js preinstalled.
🌐
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) ...
🌐
npm
docs.npmjs.com › downloading-and-installing-node-js-and-npm
Downloading and installing Node.js and npm | npm Docs
To publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node.js and npm.
🌐
Bobcares
bobcares.com › blog › uninstall-nodejs-ubuntu
How to Uninstall nodejs in Ubuntu?
July 15, 2024 - We can quickly uninstall node.js in Ubuntu using Command line with these steps from our Techs.
🌐
Scaler
scaler.com › topics › uninstall-node-js
How to uninstall Node.js? - Scaler Topics
April 26, 2024 - 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, ...
🌐
Linux Hint
linuxhint.com › completely-uninstall-nodejs-npm-and-node-in-ubuntu
How Can I Completely Uninstall Nodejs, NPM and Node in Ubuntu – Linux Hint
Node.js, NPM and Node can be removed from Ubuntu through repository via the apt command or from source directory via rm -rf command.
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › javascript › nodejs-on-windows
Set up Node.js on native Windows | Microsoft Learn
For help with removing previous installations, see How to completely remove node.js from Windows.) ... NVM is designed to be installed per-user, and invoked per-shell. It is not designed for shared developer boxes or build servers with multiple build agents. NVM works by using a symbolic link. Using nvm in shared scenarios creates a problem because that link points to a user's app data folder -- so if user x runs nvm use lts, the link will point node for the entire box to their app data folder.