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
🌐
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.
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.

🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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 Uninstall
May 13, 2025 - 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 unistall them. If you installed Node.js using Ubuntu’s package manager:
Find elsewhere
🌐
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) ...
🌐
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.
🌐
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.
🌐
Scaler
scaler.com › topics › uninstall-node-js
How to uninstall Node.js? - Scaler Topics
September 22, 2023 - 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, ...
🌐
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.
🌐
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.
🌐
ByteXD
bytexd.com › how-to-uninstall-nodejs-in-ubuntu
How to Uninstall NodeJS in Ubuntu 22.04 - ByteXD
July 31, 2022 - This tutorial simplifies NodeJS uninstallation by explaining the workings of package managers, installation directories and the most suitable commands to apply. Lastly, it takes you through practical examples of uninstalling NodeJS in Ubuntu.
🌐
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.
🌐
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.