Trying to install npm
using command sudo apt-get install npm
on Ubuntu 18.04.2 LTS. expected 6.14.7
to be installed but 3.5.2
is being installed.
Asked
Active
Viewed 5,578 times
3

Thomas Ward
- 74,764
-
1You need to install NodeJS from their repositories, the Ubuntu repositoreis have old NodeJS for 18.04. Refer to https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm for more details and how to install newer NodeJS and npm. (if I vote to close this it'll be instant-closed, so make sure the linked question actually solves your problem first) – Thomas Ward Sep 16 '20 at 17:01
-
@ThomasWard, It was working fine two days ago. with apt-get. – Rakesh Ranjan Sep 16 '20 at 17:11
-
1Doubtful as the node js versions are ancient in 18.04 and have been that way since its release (2018). – Thomas Ward Sep 16 '20 at 17:13
-
node version that I'm using is 8.10.0 and npm version is 6.14.7. I have been working on this project past 6 months and never ever used PPA or binary files. today I tried to setup my project on a new server and this was the issue. – Rakesh Ranjan Sep 16 '20 at 17:17
-
1then your 'new server' had a locally installed NodeJS somewhere - that's the only way you got 'newer' NodeJS and npm. I'm sorry, but there's no other explanation than someone installed/compiled newere NOdeJS and npm in your environment – Thomas Ward Sep 16 '20 at 17:18
1 Answers
2
Here is a guide to installing newer version of NPM on Ubuntu 18.XX using a PPA:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04
You can also use NodeSource:
https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/

SimpliFixed
- 179
- 7
-
I tried using the NodeSource and install 12.x but on node js is installed with version 8.10.0. – Rakesh Ranjan Sep 16 '20 at 18:05