{"id":7761,"date":"2024-02-09T16:12:48","date_gmt":"2024-02-09T16:12:48","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=7761"},"modified":"2024-02-09T16:12:50","modified_gmt":"2024-02-09T16:12:50","slug":"how-to-install-npm-debian-ubuntu-centos-rhel-linux","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/","title":{"rendered":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en.jpg\" alt=\"Install NPM on Linux: Step-by-Step Guide for Debian, Ubuntu, CentOS, RHEL\" class=\"wp-image-7781\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p><strong>NPM <\/strong>(Node Package Manager) is a command line utility for installing, sharing and managing Node.js packages and modules. It is a package manager for the JavaScript programming language. NPM is installed with Node.js and allows developers to easily share and reuse code from the NPM registry.<\/p>\n\n\n\n<p>In this extensive tutorial, we will cover how to install NPM on Debian\/Ubuntu and CentOS\/RHEL operating systems in detail. We&#8217;ll go over checking existing installations, uninstalling old versions if needed, and walk through the installation process step-by-step. Let&#8217;s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"checking-for-existing-installations\">Checking for Existing Installations<\/h2>\n\n\n\n<p>Before installing or reinstalling NPM, it&#8217;s a good idea to check if you already have Node.js and NPM installed and which versions currently exist on your system.<\/p>\n\n\n\n<p>Open a terminal and type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<p>If Node.js and NPM are installed, these commands will show the current version number. For example, on my system I see:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\nv18.19.0\n\n$ npm --version  \n10.2.3<\/code><\/pre>\n\n\n\n<p>This output indicates I already have Node v18.19.0 and NPM v10.2.3 installed.<\/p>\n\n\n\n<p>If these commands don&#8217;t return a version number it likely means that Node.js and NPM are not installed on your system yet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"removing-old-versions-if-required\">Removing Old Versions (If Required)<\/h2>\n\n\n\n<p>If you have an older version installed that you want to replace, we&#8217;ll go over how to remove Node.js and NPM cleanly from Debian\/Ubuntu and CentOS\/RHEL systems.<\/p>\n\n\n\n<p><strong>Note<\/strong>: Removing old installations is only required if you want to completely wipe out the existing version and dependencies for a new fresh install. If you&#8217;re fine with the current version and just want the latest updates, you can skip ahead to the installation sections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"uninstall-nodejs-on-debianubuntu\">Uninstall Node.js on Debian\/Ubuntu<\/h3>\n\n\n\n<p>To remove Node.js on Debian\/Ubuntu, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt-get remove nodejs\n$ sudo apt-get purge nodejs\n$ sudo apt-get autoremove<\/code><\/pre>\n\n\n\n<p>This will uninstall Node.js from your system along with any related packages and configuration files.<\/p>\n\n\n\n<p>You can also run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt-get remove --purge nodejs npm<\/code><\/pre>\n\n\n\n<p>This will remove Node.js as well as NPM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"uninstall-nodejs-on-centosrhel\">Uninstall Node.js on CentOS\/RHEL<\/h3>\n\n\n\n<p>To uninstall Node.js on CentOS\/RHEL, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum remove nodejs\n$ sudo yum autoremove<\/code><\/pre>\n\n\n\n<p>This will remove the Node.js package and clean up any dependencies.<\/p>\n\n\n\n<p>To also remove NPM, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum remove npm<\/code><\/pre>\n\n\n\n<p>With the old installations removed, you are ready to install the latest version of Node.js and NPM on your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-on-debianubuntu\">Installing on Debian\/Ubuntu<\/h2>\n\n\n\n<p>There are a few different options for installing Node.js and NPM on Debian and Ubuntu systems. We&#8217;ll go over using the default repositories and then some alternative installation methods.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-from-default-repositories\">Installing from Default Repositories<\/h3>\n\n\n\n<p>This method involves installing Node.js and NPM from the default Ubuntu repositories. The versions included may not be the latest, but this is a reliable way to install on Ubuntu systems.<\/p>\n\n\n\n<p>To install both Node.js and NPM, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt update\n$ sudo apt install nodejs npm<\/code><\/pre>\n\n\n\n<p>This will install Node.js and NPM from the Ubuntu repositories and automatically install some dependencies as well.<\/p>\n\n\n\n<p>You can verify the installed versions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-nodesource-repository\">Using NodeSource Repository<\/h3>\n\n\n\n<p>A popular alternative is to add the NodeSource repository to apt and install from there. This lets you install a more up-to-date version of Node.js than what is available in the default Ubuntu repositories.<\/p>\n\n\n\n<p>First check the latest Node.js LTS version available from the NodeSource site:&nbsp;<a href=\"https:\/\/github.com\/nodesource\/distributions\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/nodesource\/distributions<\/a><\/p>\n\n\n\n<p>As of writing, the latest LTS version is Node 18.x which is what we&#8217;ll use here. But check for the latest version before installing.<\/p>\n\n\n\n<p>First, install the NodeSource PPA to get access to its contents:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -sL https:\/\/deb.nodesource.com\/setup_18.x | sudo -E bash -<\/code><\/pre>\n\n\n\n<p>Note: Change the version number in the URL after &#8216;setup_&#8217; to match the latest LTS version you want to install.<\/p>\n\n\n\n<p>The PPA has been added and your system repositories updated. Now install Node.js and npm:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt-get install -y nodejs<\/code><\/pre>\n\n\n\n<p>Finally, verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-node-version-manager-nvm\">Using Node Version Manager (nvm)<\/h3>\n\n\n\n<p>An even more flexible option is to install the nvm script which allows you to easily install and switch between multiple versions of Node on the same system.<\/p>\n\n\n\n<p>To install nvm on Ubuntu, first install the build tools required for some of the packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt update\n$ sudo apt install build-essential libssl-dev<\/code><\/pre>\n\n\n\n<p>Then install nvm with curl and activate it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.39.7\/install.sh | bash  \nexport NVM_DIR=\"$([ -z \"${XDG_CONFIG_HOME-}\" ] &amp;&amp; printf %s \"${HOME}\/.nvm\" || printf %s \"${XDG_CONFIG_HOME}\/nvm\")\"\n$ [ -s \"$NVM_DIR\/nvm.sh\" ] &amp;&amp; \\. \"$NVM_DIR\/nvm.sh\" <em># This loads nvm<\/em><\/code><\/pre>\n\n\n\n<p>With nvm installed, you can now easily install any version of Node like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm install 18.19.0<\/code><\/pre>\n\n\n\n<p>Use the latest LTS version instead of 18.19.0.<\/p>\n\n\n\n<p>And switch between versions like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm use 18.19.0<\/code><\/pre>\n\n\n\n<p>You can list all versions installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm list<\/code><\/pre>\n\n\n\n<p>And use nvm to install NPM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm install-latest-npm<\/code><\/pre>\n\n\n\n<p>This installation method gives you complete control over Node versions installed on your system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"building-from-source\">Building from Source<\/h3>\n\n\n\n<p>Another option is to build Node from source. This allows you to install Node with specific custom configurations if needed.<\/p>\n\n\n\n<p>First, install the build tools required:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo apt-get install gcc g++ make<\/code><\/pre>\n\n\n\n<p>Then download the latest Node source code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -sL https:\/\/nodejs.org\/dist\/v18.19.0\/node-v18.19.0.tar.gz -o node.tar.gz<\/code><\/pre>\n\n\n\n<p>Replace the version 18.19.0 with the desired version number. Then extract the tarball:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -xzf node.tar.gz<\/code><\/pre>\n\n\n\n<p>Move into the extracted directory and configure for build:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cd node-v*\n$ .\/configure<\/code><\/pre>\n\n\n\n<p>Now build and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ make\n$ sudo make install<\/code><\/pre>\n\n\n\n<p>Lastly, verify install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<p>This installation method allows for custom configurations but is more complex than the other methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-on-centosrhel\">Installing on CentOS\/RHEL<\/h2>\n\n\n\n<p>Similar to Ubuntu, CentOS\/RHEL has several options for installing Node.js and NPM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-from-default-repositories-1\">Installing from Default Repositories<\/h3>\n\n\n\n<p>This involves installing from the default package repositories on CentOS\/RHEL systems. The version will not be the latest but it&#8217;s a stable way to install.<\/p>\n\n\n\n<p>For CentOS\/RHEL 7:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum install nodejs<\/code><\/pre>\n\n\n\n<p>For CentOS\/RHEL 8:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ dnf module install nodejs:18<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-nodesource-repository-1\">Using NodeSource Repository<\/h3>\n\n\n\n<p>A popular alternative is to add the NodeSource repository and install from there. This gives you access to more up-to-date Node.js versions.<\/p>\n\n\n\n<p>First check the latest available versions from NodeSource here:&nbsp;<a href=\"https:\/\/github.com\/nodesource\/distributions\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/nodesource\/distributions<\/a><\/p>\n\n\n\n<p>As of this writing, the latest LTS is v18.x so we will use that:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum install -y gcc-c++ make<\/code><\/pre>\n\n\n\n<p>This installs some required build tools first. Then add the NodeSource repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -sL https:\/\/rpm.nodesource.com\/setup_18.x | sudo bash -<\/code><\/pre>\n\n\n\n<p>Install Node.js and npm:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum install nodejs<\/code><\/pre>\n\n\n\n<p>Check versions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-nvm\">Using nvm<\/h3>\n\n\n\n<p>You can also install nvm to manage multiple Node.js versions on CentOS\/RHEL.<\/p>\n\n\n\n<p>Install the required build tools:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum install gcc-c++ make<\/code><\/pre>\n\n\n\n<p>Then install nvm:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.39.7\/install.sh | bash<\/code><\/pre>\n\n\n\n<p>Activate nvm:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ export NVM_DIR=\"$([ -z \"${XDG_CONFIG_HOME-}\" ] &amp;&amp; printf %s \"${HOME}\/.nvm\" || printf %s \"${XDG_CONFIG_HOME}\/nvm\")\"\n$ [ -s \"$NVM_DIR\/nvm.sh\" ] &amp;&amp; \\. \"$NVM_DIR\/nvm.sh\" <em># This loads nvm<\/em><\/code><\/pre>\n\n\n\n<p>Now you can install any Node.js version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm install 18.19.0  <\/code><\/pre>\n\n\n\n<p>Switch between installed versions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm use 18.19.0<\/code><\/pre>\n\n\n\n<p>List installed versions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm list<\/code><\/pre>\n\n\n\n<p>Install NPM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm install-latest-npm<\/code><\/pre>\n\n\n\n<p>Using nvm gives you the flexibility to install and manage multiple Node.js versions as needed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"building-from-source-1\">Building from Source<\/h3>\n\n\n\n<p>You can also compile Node from source if you want custom configurations.<\/p>\n\n\n\n<p>Install the required build tools:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo yum groupinstall \"Development Tools\"<\/code><\/pre>\n\n\n\n<p>Download the desired Node version source code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ curl -sL https:\/\/nodejs.org\/dist\/v18.19.0\/node-v18.19.0.tar.gz -o node.tar.gz <\/code><\/pre>\n\n\n\n<p>Replace 18.19.0 with your desired version.<\/p>\n\n\n\n<p>Extract the tarball:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ tar -xzf node.tar.gz<\/code><\/pre>\n\n\n\n<p>Move into the extracted directory and configure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cd node-v*  \n$ .\/configure<\/code><\/pre>\n\n\n\n<p>Build and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ make\n$ sudo make install <\/code><\/pre>\n\n\n\n<p>Verify installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ node --version\n$ npm --version<\/code><\/pre>\n\n\n\n<p>While more complex than other methods, building from source allows custom configuration options.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"updating-npm\">Updating NPM<\/h2>\n\n\n\n<p>If Node.js and NPM are already installed and you want to update to the latest version, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo npm install -g npm@latest<\/code><\/pre>\n\n\n\n<p>This uses NPM to update itself to the latest available version.<\/p>\n\n\n\n<p>Or to update to a specific version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ sudo npm install -g npm@10.2.3<\/code><\/pre>\n\n\n\n<p>Replace 10.2.3 with the NPM version number you want to update to.<\/p>\n\n\n\n<p>You can also use the Node Version Manager (nvm) to update to the latest NPM version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ nvm install-latest-npm<\/code><\/pre>\n\n\n\n<p>This will install the latest available NPM version for the active Node.js version on the system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"usage\">Usage<\/h2>\n\n\n\n<p>With NPM installed, you can now use various npm commands to install and manage packages.<\/p>\n\n\n\n<p>To install a package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm install &lt;package_name&gt;<\/code><\/pre>\n\n\n\n<p>This installs the latest version of the package to the local node_modules folder in your current working directory.<\/p>\n\n\n\n<p>To install a package globally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm install -g &lt;package_name&gt;  <\/code><\/pre>\n\n\n\n<p>Global packages are installed to the system&#8217;s global node_modules folder and can be accessed from anywhere on the system.<\/p>\n\n\n\n<p>To install a specific package version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm install &lt;package_name&gt;@&lt;version&gt;<\/code><\/pre>\n\n\n\n<p>Replace&nbsp;with the package semver number you want to install.<\/p>\n\n\n\n<p>Update packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm update  <\/code><\/pre>\n\n\n\n<p>This updates all packages in the current working directory to their latest versions.<\/p>\n\n\n\n<p>To list installed packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm list<\/code><\/pre>\n\n\n\n<p>This lists all the packages installed in the local folder.<\/p>\n\n\n\n<p>To see all installed global packages:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ npm list -g --depth 0<\/code><\/pre>\n\n\n\n<p>There are many more NPM commands for publishing packages, managing dependencies, running scripts and more. Some other commonly used commands include:<\/p>\n\n\n\n<ul>\n<li><code>npm init<\/code>&nbsp;&#8211; Create a new package.json file<\/li>\n\n\n\n<li><code>npm test<\/code>&nbsp;&#8211; Run tests for a package<\/li>\n\n\n\n<li><code>npm start<\/code>&nbsp;&#8211; Run the start script defined in package.json<\/li>\n\n\n\n<li><code>npm run &lt;script_name&gt;<\/code>&nbsp;&#8211; Run a custom defined script<\/li>\n\n\n\n<li><code>npm outdated<\/code>&nbsp;&#8211; Check for outdated packages<\/li>\n\n\n\n<li><code>npm uninstall &lt;package_name&gt;<\/code>&nbsp;&#8211; Uninstall a package<\/li>\n<\/ul>\n\n\n\n<p>For an extensive reference on all npm commands, visit:&nbsp;<a href=\"https:\/\/docs.npmjs.com\/cli\/v10\/commands\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.npmjs.com\/cli\/v10\/commands<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this comprehensive article, we covered how to check for existing Node.js and NPM installations, remove old versions if needed, and various methods for installing or updating NPM on Debian\/Ubuntu and CentOS\/RHEL systems.<\/p>\n\n\n\n<p>We went over using the default repositories, NodeSource, Node Version Manager (nvm), building from source code, and updating NPM to the latest version. We also touched on some of the most commonly used NPM commands and usage once installed.<\/p>\n\n\n\n<p>NPM is an indispensable tool for any JavaScript developer. Following these step-by-step instructions should give you the knowledge to install and manage NPM on your chosen Linux distribution. Feel free to refer back to this guide whenever you need to install, update or manage NPM on a Linux system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NPM (Node Package Manager) is a command line utility for installing, sharing and managing Node.js packages and modules. It is a package manager for the JavaScript programming language. NPM is installed with Node.js and allows developers to easily share and reuse code from the NPM registry. In this extensive tutorial, we will cover how to ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[188,69],"tags":[],"yoast_head":"\n<title>How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-09T16:12:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-09T16:12:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL\",\"datePublished\":\"2024-02-09T16:12:48+00:00\",\"dateModified\":\"2024-02-09T16:12:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\"},\"wordCount\":1445,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"CMS &amp; Web development\",\"Linux system administration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\",\"name\":\"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2024-02-09T16:12:48+00:00\",\"dateModified\":\"2024-02-09T16:12:50+00:00\",\"description\":\"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations","description":"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations","og_description":"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.","og_url":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2024-02-09T16:12:48+00:00","article_modified_time":"2024-02-09T16:12:50+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2024\/02\/npm_install_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL","datePublished":"2024-02-09T16:12:48+00:00","dateModified":"2024-02-09T16:12:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/"},"wordCount":1445,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["CMS &amp; Web development","Linux system administration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/","url":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/","name":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2024-02-09T16:12:48+00:00","dateModified":"2024-02-09T16:12:50+00:00","description":"Learn how to install NPM (Node Package Manager) on Debian\/Ubuntu and CentOS\/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/how-to-install-npm-debian-ubuntu-centos-rhel-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"How to Install NPM on Debian\/Ubuntu or CentOS\/RHEL"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1784239260","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/7761"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=7761"}],"version-history":[{"count":8,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/7761\/revisions"}],"predecessor-version":[{"id":7797,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/7761\/revisions\/7797"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=7761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=7761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=7761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}