0

Im using npm to update npm. It says that it updates it but the version stays the same (I have run this many times). Any help is appriciated.

felix:~/job (dev) $ npm --version
5.6.0

felix:~/job (dev) $ npm install npm@latest -g
/home/felix/.npm-global/bin/npm -> /home/felix/.npmglobal/lib/node_modules/npm/bin/npm-cli.js
/home/felix/.npm-global/bin/npx -> /home/felix/.npm-global/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.1.0
updated 1 package in 4.939s

felix:~/job (dev) $ npm --version
5.6.0

I've also tried to do:

felix:~/job (dev) $ curl https://www.npmjs.com/install.sh | sh
module.js:549    curl https://www.npmjs.com/install.sh | sh
    throw err;
    ^

Error: Cannot find module '/tmp/npm.30077/package/bin/read-package-json.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
removed 682 packages in 3.11s
/home/felix/.npm-global/bin/npm -> /home/felix/.npm-global/lib/node_modules/npm/bin/npm-cli.js
/home/felix/.npm-global/bin/npx -> /home/felix/.npm-global/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.1.0
added 1 package from 572 contributors in 1.413s
It worked
felix:~/job (dev) $ npm --version
5.6.0

This also threw an error. And I'm not quite sure why.

mrfr
  • 1,724
  • 2
  • 23
  • 44

1 Answers1

0

I just had the exact same problem, even npm view npm version was returning 6.4.0 for me but npm -v still printed out 5.3.0.

Following this link: https://gist.github.com/DanHerbert/9520689 I uninstalled node from(with) Homebrew and reinstalled (still using Homebrew) it without npm, then installed npm separately, with official .sh.

That said, you mentioned that you have Linux, so that might not be the case with your issue, but this information might get you some ideas of what can be the case or help others, so posting in case :)

Good luck!

Oto Meskhy
  • 116
  • 4