0

Here is how I install NPM on a Linux Mint 19.

sudo apt install nodejs
sudo apt install npm

The NPM version I get is 3.5.2, which is not the current version. To upgrade, I try the following commands.

sudo npm install latest-version

which has a few warning messages such as "not such file or directory, open '/home/me/package.json'" and sudo mpn install npm@latest -g which runs without any warning or error messages.

The command

npm -v

still yields 3.5.2.

What is missing?

Also, the reason of using sudo in those upgrade commands is to work around some access permission.

vic
  • 2,548
  • 9
  • 44
  • 74

3 Answers3

0

try running:

which npm

and

sudo which npm

I suspect by running sudo apt-get ... you installed npm for your root user as opposed to your current user.

ACVM
  • 1,497
  • 8
  • 14
  • The command with sudo and without sudo yields the same path which is /usr/local/bin/npm – vic Oct 01 '18 at 20:41
0

Try this command: npm install -g npm@latest or npm install -g npm@next

-1

You can update NPM with: npm install -g npm.

See this Q&A for more variations that might occur/needed.

Rivasa
  • 6,510
  • 3
  • 35
  • 64
  • You should most definitely **never ever** do `sudo npm` *anything*. In general a sane development workflow never ever requires root; once it does you know you are doing something wrong. ;) If you must `npm install -g`, use the `prefix` feature of your `~/.npmrc` & `NODE_PATH` to point somewhere in your own home directory. Then you can do `npm -g install` without requiring root ever again. – user268396 Oct 01 '18 at 20:39