How to install npm on Ubuntu


If you are trying to install an npm module and you get an error then you are missing Node.js you need to install it using apt command.

$ sudo apt install nodejs
 $ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libc-ares2 libnode64 nodejs-doc
Suggested packages:
  npm
The following NEW packages will be installed:
  libc-ares2 libnode64 nodejs nodejs-doc
0 upgraded, 4 newly installed, 0 to remove and 152 not upgraded.
Need to get 6807 kB of archives.
After this operation, 30.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libc-ares2 amd64 1.15.0-1build1 [37.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libnode64 amd64 10.19.0~dfsg-3ubuntu1 [5765 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 nodejs-doc all 10.19.0~dfsg-3ubuntu1 [942 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 nodejs amd64 10.19.0~dfsg-3ubuntu1 [61.1 kB]
Fetched 6807 kB in 35s (195 kB/s)
Selecting previously unselected package libc-ares2:amd64.
(Reading database ... 39318 files and directories currently installed.)
Preparing to unpack .../libc-ares2_1.15.0-1build1_amd64.deb ...
Unpacking libc-ares2:amd64 (1.15.0-1build1) ...
Selecting previously unselected package libnode64:amd64.
Preparing to unpack .../libnode64_10.19.0~dfsg-3ubuntu1_amd64.deb ...
Unpacking libnode64:amd64 (10.19.0~dfsg-3ubuntu1) ...
Selecting previously unselected package nodejs-doc.
Preparing to unpack .../nodejs-doc_10.19.0~dfsg-3ubuntu1_all.deb ...
Unpacking nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_10.19.0~dfsg-3ubuntu1_amd64.deb ...
Unpacking nodejs (10.19.0~dfsg-3ubuntu1) ...
Setting up libc-ares2:amd64 (1.15.0-1build1) ...
Setting up libnode64:amd64 (10.19.0~dfsg-3ubuntu1) ...
Setting up nodejs-doc (10.19.0~dfsg-3ubuntu1) ...
Setting up nodejs (10.19.0~dfsg-3ubuntu1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for man-db (2.9.1-1) ...
$ npm install bootstrap

Command 'npm' not found, but can be installed with:

Now, you should install npm,

$ apt install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  gyp javascript-common 
  node-wrap-ansi 
  node-wrappy 
  ...
  node-write-file-atomic
  python2 
  python2-minimal
  python2.7 
  python2.7-minimal x
  11-xserver-utils
  xdg-utils


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap