Node.js<\/a> and NPM. You can do this by opening your terminal and running the following commands:<\/p>\n\n\n\nTo check the Node.js version:<\/p>\n\n\n\n
$ node -v<\/code><\/pre>\n\n\n\nTo check the NPM version:<\/p>\n\n\n\n
$ npm -v<\/code><\/pre>\n\n\n\nThis step helps you verify which versions you have installed so you can ensure they are removed correctly.<\/p>\n\n\n\n
Step 2: Uninstall Node.js and NPM<\/strong><\/h2>\n\n\n\nTo uninstall Node.js and NPM from your Ubuntu system, you can use the package manager apt<\/code>. Here are the commands to remove them:<\/p>\n\n\n\n\nRemove Node.js: sudo apt-get remove nodejs<\/code><\/li>\n\n\n\nRemove NPM: sudo apt-get remove npm<\/code><\/li>\n\n\n\nAdditionally, you may want to remove any residual configuration files for Node.js and NPM: sudo apt-get purge nodejs npm<\/code><\/li>\n<\/ol>\n\n\n\nStep 3: Verify Uninstallation<\/strong><\/h2>\n\n\n\nAfter running the uninstallation commands, it’s a good practice to verify that Node.js and NPM have been successfully removed. To check this, run the following commands:<\/p>\n\n\n\n
$ node -v npm -v<\/code><\/pre>\n\n\n\nIf the commands return an error or indicate that the program is not installed, it means Node.js and NPM have been successfully uninstalled from your system.<\/p>\n\n\n\n
Step 4: Remove Node.js and NPM Global Packages<\/strong><\/h2>\n\n\n\nUninstalling Node.js and NPM from your system does not remove global Node packages you may have installed. To remove these global packages, you can use the npm list -g --depth=0<\/code> command to list them, and then use npm uninstall -g<\/code> to uninstall them one by one.<\/p>\n\n\n\nFor example, to list your global packages:<\/p>\n\n\n\n
$ npm list -g --depth=0<\/code><\/pre>\n\n\n\nTo uninstall a global package (replace package_name<\/code> with the actual package name):<\/p>\n\n\n\n$ npm uninstall -g package_name<\/code><\/pre>\n\n\n\n\n
Repeat the uninstallation process for each global package you want to remove.<\/p>\n<\/div>\n\n\n\n
Step 5: Remove Node.js and NPM Files and Directories<\/strong><\/h2>\n\n\n\nAfter uninstalling Node.js and NPM, there may still be residual files and directories left on your system. To remove them, use the following commands:<\/p>\n\n\n\n
\nDelete the \/usr\/local\/bin\/node<\/code> binary: sudo rm -rf \/usr\/local\/bin\/node<\/code><\/li>\n\n\n\nRemove any related files in the \/usr\/local\/lib<\/code> directory: sudo rm -rf \/usr\/local\/lib\/node*<\/code><\/li>\n\n\n\nDelete the \/usr\/local\/bin\/npm<\/code> binary: sudo rm -rf \/usr\/local\/bin\/npm<\/code><\/li>\n\n\n\nRemove any related files in the \/usr\/local\/lib<\/code> directory: sudo rm -rf \/usr\/local\/lib\/npm*<\/code><\/li>\n<\/ol>\n\n\n\nStep 6: Clear the Cache<\/strong><\/h2>\n\n\n\nNode.js and NPM may leave behind cached files that you can remove. To do this, use the following command:<\/p>\n\n\n\n
$ sudo npm cache clean -f<\/code><\/pre>\n\n\n\nConclusion<\/strong><\/h2>\n\n\n\nUninstalling Node.js, NPM, and Node from your Ubuntu system can be necessary for various reasons, and it’s crucial to do it correctly to avoid any issues. By following these steps, you should be able to completely remove Node.js and NPM from your machine, including any residual files and global packages. This ensures a clean uninstallation, allowing you to install or upgrade Node.js with a fresh start when needed.<\/p>\n","protected":false},"excerpt":{"rendered":"
Node.js is a popular runtime environment that allows you to run JavaScript on the server-side. While it’s an essential tool for many developers, there may come a time when you…<\/p>\n","protected":false},"author":1,"featured_media":13766,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16,18],"tags":[193,328,354,404,424,433,449,531,544,573,591,598,636,638],"yoast_head":"\n
How to Completely Uninstall Node.js, NPM, and Node in Ubuntu<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n