{"id":25978,"date":"2024-02-29T15:20:36","date_gmt":"2024-02-29T15:20:36","guid":{"rendered":"https:\/\/linuxways.net\/?p=25978"},"modified":"2024-02-29T15:20:36","modified_gmt":"2024-02-29T15:20:36","slug":"install-npm-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/install-npm-ubuntu-22-04\/","title":{"rendered":"How to Install NPM on Ubuntu 22.04"},"content":{"rendered":"<p><strong>NPM<\/strong> is the package manager of the <strong>Node.js<\/strong> programming language. It is the largest code library containing more than 2 million code packages. It functions by managing the code dependencies of different servers.<strong> NPM<\/strong> packages streamline the process of application development because of their well-maintained and well-organized code structure.<\/p>\n<p><strong>NPM <\/strong>package manager assists in installing and running the JavaScript applications on Ubuntu. It automatically handles the JavaScript packages by installing the necessary libraries and frameworks needed to run the JS applications.<\/p>\n<p>In this article, you will learn:<\/p>\n<ul>\n<li><a href=\"#post-25978-_iwttlcxv04by\">How to Install NPM on Ubuntu 22.04<\/a><\/li>\n<li><a href=\"#post-25978-_m60rxjcdbrja\">How to remove NPM from Ubuntu 22.04<\/a><\/li>\n<li><a href=\"#post-25978-_8ucczllsgv7\">Conclusion<\/a><\/li>\n<\/ul>\n<h2><a id=\"post-25978-_iwttlcxv04by\"><\/a>How to Install NPM on Ubuntu 22.04<\/h2>\n<p>Here are the methods through which you can install <strong>NPM <\/strong>on Ubuntu 22.04:<\/p>\n<ul>\n<li><a href=\"#post-25978-_fm1hlksun3qg\">apt<\/a><\/li>\n<li><a href=\"#post-25978-_qyi5qix2txhd\">NVM<\/a><\/li>\n<li><a href=\"#post-25978-_wv8t6bxegwgs\">NodeSource (PPA)<\/a><\/li>\n<\/ul>\n<h3><a id=\"post-25978-_fm1hlksun3qg\"><\/a>Method 1: Install NPM on Ubuntu 22.04 Using apt Package Manager<\/h3>\n<p>The default method to install the <strong>NPM<\/strong> package on Ubuntu is the apt command-line tool. It is a package manager in Linux that installs, removes, updates, or upgrades the applications. Go through the following step-by-step instructions to install <strong>NPM<\/strong> on Ubuntu 22.04 using the apt command:<\/p>\n<p><strong>Step 1: Update apt Repository Packages<\/strong><\/p>\n<p>Make sure to update the system repositories before installing <strong>NPM<\/strong> by running the mentioned command in Terminal:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"962\" height=\"282\" class=\"wp-image-25986\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-1.png 962w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-1-300x88.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-1-768x225.png 768w\" sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><\/p>\n<p><strong>Step 2: Install NPM on Ubuntu<\/strong><\/p>\n<p>Open Terminal and execute the mentioned command to install <strong>NPM<\/strong> on Ubuntu 22.04:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> npm <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"242\" class=\"wp-image-25990\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-2.png 804w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-2-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-2-768x231.png 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/p>\n<p><strong>Step 3: Verify the NPM Installation<\/strong><\/p>\n<p>Once the <strong>NPM<\/strong> is installed, verify its installation by checking its version using the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">npm <span class=\"re5\">--version<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"114\" class=\"wp-image-25995\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-3.png 806w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-3-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-3-768x109.png 768w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/p>\n<p>The version confirms that the NPM package manager is successfully installed.<\/p>\n<h3><a id=\"post-25978-_qyi5qix2txhd\"><\/a>Method 2: Install NPM on Ubuntu 22.04 Using NVM<\/h3>\n<p>The <strong>NVM <\/strong>\u201c<strong>Node Version Manager<\/strong>\u201d is an alternate method to install the <strong>NPM<\/strong> on Ubuntu. <strong>NVM <\/strong>checks the existence of <strong>Node.js<\/strong> on the system, gets the available version that can be installed on Ubuntu, and allows the user to install the desired <strong>Node.js<\/strong> version. Installing the<strong> Node.js<\/strong> via the <strong>NVM<\/strong> package manager will also install the <strong>NPM<\/strong> on Ubuntu automatically because it contains the <strong>NPM<\/strong> package inside it.<\/p>\n<p>Let\u2019s overview the stepwise instructions below to install <strong>NPM <\/strong>on Ubuntu 22.04 through NVM.<\/p>\n<p><strong>Step 1: Install NVM on Ubuntu<\/strong><\/p>\n<p>Before installing <strong>NVM<\/strong>, verify its latest version by visiting the <a href=\"https:\/\/github.com\/nvm-sh\/nvm\">GitHub link<\/a>. You can copy the script by navigating to the given link and then paste it to the Terminal to download <strong>NVM<\/strong> using the curl command line tool.<\/p>\n<p>Execute this command to download and install <strong>NVM<\/strong> version <strong>0.39.7<\/strong> on Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">curl <span class=\"re5\">-o-<\/span> https:<span class=\"sy0\">\/\/<\/span>raw.githubusercontent.com<span class=\"sy0\">\/<\/span>nvm-sh<span class=\"sy0\">\/<\/span>nvm<span class=\"sy0\">\/<\/span>v0.39.7<span class=\"sy0\">\/<\/span>install.sh <span class=\"sy0\">|<\/span> <span class=\"kw2\">bash<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1006\" height=\"226\" class=\"wp-image-26002\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-4.png 1006w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-4-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-4-768x173.png 768w\" sizes=\"auto, (max-width: 1006px) 100vw, 1006px\" \/><\/p>\n<p><strong>Step 2: Source .bashrc File<\/strong><\/p>\n<p>After installing <strong>NVM<\/strong> on Ubuntu, run the mentioned script to load changes to the system:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">source<\/span> ~<span class=\"sy0\">\/<\/span>.bashrc<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"92\" class=\"wp-image-26012\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-5.png 825w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-5-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-5-768x86.png 768w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/><\/p>\n<p><strong>Step 3: Install Node.js and NPM<\/strong><\/p>\n<p>Before installing let&#8217;s check the currently installed versions of <strong>Node.js <\/strong>on Ubuntu by running this command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"398\" class=\"wp-image-26023\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-6.png 710w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-6-300x168.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/p>\n<p>It can be observed that there are no <strong>Node.js <\/strong>versions installed on Ubuntu.<\/p>\n<p>Now, let&#8217;s check which <strong>Node.js<\/strong> versions we can install on Ubuntu by running this command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm list-remote<\/div><\/div>\n<p>This will list down all the <strong>Node.js <\/strong>versions we can install on Ubuntu:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"685\" height=\"201\" class=\"wp-image-26033\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-7.png 685w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-7-300x88.png 300w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/p>\n<p>There is a long list of <strong>Node.js <\/strong>versions we can install on Ubuntu.<\/p>\n<p>Let&#8217;s install the <strong>Node.js v20.11.1<\/strong> version on Ubuntu, by executing the mentioned command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm <span class=\"kw2\">install<\/span> v20.11.1<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"249\" class=\"wp-image-26041\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-8.png 802w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-8-300x93.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-8-768x238.png 768w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/p>\n<p>The specified <strong>Node.js <\/strong>version is installed on Ubuntu 22.04.<\/p>\n<p>Let&#8217;s list down the <strong>Node.js <\/strong>version to check whether it is installed on Ubuntu or not:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm list<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"201\" class=\"wp-image-26051\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-9.png 801w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-9-300x75.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-9-768x193.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<p><strong>Step 4: Verify Node.js and NPM Installation<\/strong><\/p>\n<p>Now, let&#8217;s check the Node.js and <strong>NPM <\/strong>versions respectively to verify the installation of <strong>NPM <\/strong>and <strong>Node.js<\/strong> via <strong>NVM<\/strong>. To check the <strong>Node.js <\/strong>version on Ubuntu, execute the given command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">node <span class=\"re5\">-v<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"113\" class=\"wp-image-26060\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-10.png 806w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-10-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-10-768x108.png 768w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/p>\n<p>Use the mentioned command to verify the <strong>NPM<\/strong> installation on Ubuntu using NVM:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">npm <span class=\"re5\">-v<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"807\" height=\"112\" class=\"wp-image-26064\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-11.png 807w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-11-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-11-768x107.png 768w\" sizes=\"auto, (max-width: 807px) 100vw, 807px\" \/><\/p>\n<h3><a id=\"post-25978-_wv8t6bxegwgs\"><\/a>Method 3: Install NPM on Ubuntu 22.04 Using PPA (NodeSource) Script<\/h3>\n<p>Alternatively, you can install the<strong> NPM<\/strong> by installing <strong>Node.js<\/strong> via a PPA repository script for Nodesource. The Nodesource is a platform used to store the <strong>Node.js<\/strong> packages. The <strong>Node.js <\/strong>package consists of both <strong>NPM <\/strong>and <strong>Node.js <\/strong>binaries, which means installing <strong>Node.js <\/strong>will also install <strong>NPM<\/strong> on Ubuntu.<\/p>\n<p>Check the steps below to install <strong>NPM<\/strong> on Ubuntu 22.04 through the NodeSource PPA repository script.<\/p>\n<p><strong>Step 1: Download and Run Nodesource PPA Repository Script<\/strong><\/p>\n<p>First, download the Nodesource PPA repository script on Ubuntu inside the<strong> \/tmp <\/strong>folder using the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">curl <span class=\"re5\">-sL<\/span> https:<span class=\"sy0\">\/\/<\/span>deb.nodesource.com<span class=\"sy0\">\/<\/span>setup_20.x <span class=\"re5\">-o<\/span> <span class=\"sy0\">\/<\/span>tmp<span class=\"sy0\">\/<\/span>nodesource_setup.sh<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"90\" class=\"wp-image-26067\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-12.png 976w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-12-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-12-768x71.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/p>\n<p><strong>Note: <\/strong>You can navigate to the <a href=\"https:\/\/deb.nodesource.com\/\">official Nodesource website<\/a> to check the latest <strong>Nodesource<\/strong> release. The current version of <strong>Nodesource <\/strong>is 20.x. However, you can install any version by replacing <strong>20.x<\/strong> in the above command with your desired version.<\/p>\n<p><strong>Step 2: Configure and Install the Necessary Packages<\/strong><\/p>\n<p>After the download is completed, run the <strong>Nodesoure<\/strong> script with the sudo command to begin the installation of the packages required to install the <strong>Node.js<\/strong> and <strong>NPM <\/strong>on Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">bash<\/span> <span class=\"sy0\">\/<\/span>tmp<span class=\"sy0\">\/<\/span>nodesource_setup.sh<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"197\" class=\"wp-image-26069\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-13.png 865w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-13-300x68.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-13-768x175.png 768w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/p>\n<p><strong>Step 3: Install Node.js and NPM Packages<\/strong><\/p>\n<p>Now, run the command similar to the first method to install node.js on Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> nodejs <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"814\" height=\"242\" class=\"wp-image-26071\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-14.png 814w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-14-300x89.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-14-768x228.png 768w\" sizes=\"auto, (max-width: 814px) 100vw, 814px\" \/><\/p>\n<p>As discussed earlier installing the node.js package will install npm.<\/p>\n<p><strong>Step 4: Check the Node.js Installation<\/strong><\/p>\n<p>check the <strong>Node.js<\/strong> version by executing the mentioned command to verify the installation of the <strong>Node.js <\/strong>package:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nodejs <span class=\"re5\">-v<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"113\" class=\"wp-image-26072\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-15.png 808w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-15-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-15-768x107.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/p>\n<p>Now let&#8217;s check the <strong>NPM<\/strong> installation on Ubuntu by executing the below command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">npm <span class=\"re5\">-v<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"116\" class=\"wp-image-26074\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-16.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-16.png 815w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-16-300x43.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-16-768x109.png 768w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>The <strong>NPM<\/strong> is successfully installed using the NodeSource (PPA).<\/p>\n<p><strong>Note<\/strong>: If you face any issues while executing the \u201c<strong>sudo apt install nodejs -y<\/strong>\u201d command. Then, execute<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">dpkg<\/span> <span class=\"re5\">-i<\/span> <span class=\"re5\">--force-overwrite<\/span> <span class=\"sy0\">\/<\/span>var<span class=\"sy0\">\/<\/span>cache<span class=\"sy0\">\/<\/span>apt<span class=\"sy0\">\/<\/span>archives<span class=\"sy0\">\/<\/span>nodejs_<span class=\"sy0\">&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span>20.11.1<span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span>-1nodesource1_amd64.deb<\/div><\/div>\n<p>Replace the highlighted version with your <strong>Node.js<\/strong> version. After that, execute the following command to fix the broken packages.,<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"re5\">-f<\/span> <span class=\"kw2\">install<\/span><\/div><\/div>\n<h2><a id=\"post-25978-_m60rxjcdbrja\"><\/a>How to Remove NPM from Ubuntu 22.04<\/h2>\n<p>You can uninstall<strong> NPM<\/strong> from Ubuntu using:<\/p>\n<ul>\n<li><a href=\"#post-25978-_qlphdvtnwsl\">APT<\/a><\/li>\n<li><a href=\"#post-25978-_uvv9mj1f2bg0\">NVM<\/a><\/li>\n<\/ul>\n<h3><a id=\"post-25978-_qlphdvtnwsl\"><\/a>Method 1: Remove NPM from Ubuntu 22.04 Using apt Package Manager<\/h3>\n<p>If you have installed Node.js through the apt package manager and NodeSource (PPA), then run the mentioned command to remove Node.js from Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt remove npm <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"268\" class=\"wp-image-26077\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-17.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-17.png 819w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-17-300x98.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-17-768x251.png 768w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p><strong>Note:<\/strong> Ubuntu retains the configuration files after the removal of any application. To remove those files alongside application removal, use the purge command instead of the remove command, as shown below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt purge npm <span class=\"re5\">-y<\/span><\/div><\/div>\n<h3><a id=\"post-25978-_uvv9mj1f2bg0\"><\/a>Method 2: Remove NPM from Ubuntu 22.04 Using NVM<\/h3>\n<p>The removal of the <strong>NPM<\/strong> package manager through NVM is explained below in the instructional steps.<\/p>\n<p><strong>Step 1: Verify the Current Node Version<\/strong><\/p>\n<p>Before removing <strong>NPM <\/strong>and <strong>Node.js<\/strong>, check the current<strong> Node.js<\/strong> version installed on Ubuntu by executing this command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm current<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"115\" class=\"wp-image-26085\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-18.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-18.png 650w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-18-300x53.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p><strong>Step 2: Deactivate NVM<\/strong><\/p>\n<p>Now, deactivate the <strong>NVM<\/strong> package manager on Ubuntu from the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm deactivate<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"113\" class=\"wp-image-26093\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-19.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-19.png 816w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-19-300x42.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-19-768x106.png 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/p>\n<p><strong>Step 3: Uninstall Node.js and NPM<\/strong><\/p>\n<p>Provide the nvm command followed by the uninstall command to remove Node.js and NPM from Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">nvm uninstall v20.11.1<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"116\" class=\"wp-image-26100\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-20.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-20.png 816w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-20-300x43.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/02\/word-image-25978-20-768x109.png 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/p>\n<h2><a id=\"post-25978-_8ucczllsgv7\"><\/a>Conclusion<\/h2>\n<p><strong>NPM<\/strong> is a package manager that provides access to code libraries and helps manage packages used in the <strong>Node.js<\/strong> projects. The <strong>NPM<\/strong> can be installed on Ubuntu using the <strong>APT command line tool (Official Repository)<\/strong>. Alternatively, you can also install <strong>NPM<\/strong> on Ubuntu using <strong>NodeSource (PPA)<\/strong>, and <strong>NVM <\/strong>package manager. Each method will let you install <strong>NPM<\/strong> on Ubuntu and help streamline your development process with <strong>Node.js.<\/strong><\/p>","protected":false},"excerpt":{"rendered":"<p>The NPM can be installed on Ubuntu using the APT command line tool. Alternatively, you can also install npm on Ubuntu using NodeSource, and NVM package manager. <\/p>","protected":false},"author":110,"featured_media":26127,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-25978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/25978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=25978"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/25978\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/26127"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=25978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=25978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=25978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}