3

I am trying to build an application using Node.js integrated into Visual Studio Code. The most important versions of the software I have are:

The version of Node.js I have is v10.15.2.

The version I have for npm is 5.8.0.

I have Ubuntu 19.04 as OS.

It seems that there is a compatibility issue with the old npm.

So I tried to do the following operations to correctly install the last version of npm:

1) npm uninstall -g npm

2) sudo npm cache clean -f

3) sudo npm install -g npm

4) npm -v but it still gives 5.8.0.

I followed the procedure described here but it doesn't seem to be working.

In addition I found this useful additional post but nothing happened.

If useful I am also posting the output of the debugger in the print-screen below:

error

Lastly after those steps I receive the following confirmation:

confirmation

But as soon as I try to check the version npm -v it still gives 5.8.0

EDITS

The following is the output after a couple of additional trials:

latest_commands

Thank you for pointing in the right direction to solve this matter.

Emanuele
  • 2,194
  • 6
  • 32
  • 71

1 Answers1

2

The default version of npm for Node 10.15.2 is 6.4.1. Depending on how you installed, the ordering of directories in your PATH environment variable will make a difference. To view all npms on your PATH, run:

which -a npm

Another helpful command is to list out your globally installed packages including where they're installed:

npm ls -g --depth=0
jcragun
  • 2,060
  • 10
  • 8
  • thank you for reading the question. I tried your suggestion and what I obtained is [this](https://i.imgur.com/ZaH7OQk.png). Any thoughts? – Emanuele Oct 31 '19 at 17:08
  • Interesting. You may need to check where Node is installed with `which -a node` and fix your `PATH` based on that. You could also run `ls -la /usr/local/bin/npm` to see if it's a symlink to `/usr/local/lib/node_modules/npm/bin/npm-cli.js` since the listing shows 6.12.1 is installed there. – jcragun Oct 31 '19 at 17:20
  • I edited the question with a couple of updates. There seems to be a symlink, that explains why is there the last correct version. what is the convention to include the `PATH` for that version? – Emanuele Oct 31 '19 at 17:27
  • Searching the `PATH` goes from left to right, with the leftmost being highest priority. For example `export PATH=~/bin:$PATH` would look in `~/bin` before `/usr/local/bin`. If the symlink is incorrect then you'd need to change it or remove it and redo the npm install. Does that help? – jcragun Nov 04 '19 at 20:43
  • Thank you that helps! your explanation combined with the answer you gave me couple of days ago solved the problem :) – Emanuele Nov 04 '19 at 21:39