npm command not found on CentOS 8 Server

 

npm command not found

I got the error npm command not found on my CentOS 8 server. Follow the below steps to install npm command on CentOS 8 / RHEL 8 server.

1. Log into your CentOS 8 server via SSH as root

2. Install npm package on the server using yum

3. Enter ‘y’ if yum ask for confirmation while installing npm.

4. Verify the installation by checking npm version.

ERROR:

npm command not found

npm command not found

STEPS:

First you must run the command ‘yum list available | grep npm’ to check the available version of npm.
 

[root@centos /]# yum list available | grep npm
npm.x86_64 1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d AppStream

 
Run the command ‘yum install npm’ to install the package.
 

[root@centos /]# yum install npm
=================================================================================
Package
Arch Version Repo Size
=================================================================================
Installing:
npm x86_64 1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d AppStream 3.7 M
Installing dependencies:
nodejs x86_64 1:10.24.0-1.module_el8.3.0+717+fa496f1d AppStream 8.8 M
Installing weak dependencies:
nodejs-full-i18n
x86_64 1:10.24.0-1.module_el8.3.0+717+fa496f1d AppStream 7.3 M
Enabling module streams:
nodejs 10

Transaction Summary
=================================================================================
Install 3 Packages

Total download size: 20 M
Installed size: 71 M
Is this ok [y/N]: y

Installed:
npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64
nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64
nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64
 

 

npm command not found - how to install npm command

npm command not found – how to install npm command


 
Npm is installed on your server. You can verify the installation by running the command ‘npm version’
 

[root@centos /]# npm version
{ npm: ‘6.14.11’,
ares: ‘1.15.0’,
brotli: ‘1.0.7’,
cldr: ‘35.1’,
http_parser: ‘2.9.4’,
icu: ‘64.2’,
modules: ’64’,
napi: ‘7’,
nghttp2: ‘1.41.0’,
node: ‘10.24.0’,
openssl: ‘1.1.1g’,
tz: ‘2019c’,
unicode: ‘12.1’,
uv: ‘1.34.2’,
v8: ‘6.8.275.32-node.59’,
zlib: ‘1.2.11’ }

 
Install npm rpm package from CentOS 8 website:
 

cd /usr/local/src/

wget http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/npm-7.21.0-1.16.8.0.1.module_el8.5.0+999+c0bf7004.x86_64.rpm

rpm -Uvh npm-7.21.0-1.16.8.0.1.module_el8.5.0+999+c0bf7004.x86_64.rpm