我无法更新我的npm版本

时间:2022-06-12 02:31:07

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.

我用npm来更新npm。它说它更新它但版本保持不变(我已经运行了很多次)。任何帮助都是适当的。

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.

这也引发了一个错误。而且我不太清楚为什么。

1 个解决方案

#1


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.

我只是有完全相同的问题,甚至npm视图npm版本为我返回6.4.0但是npm -v仍然打印出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.

点击此链接:https://gist.github.com/DanHerbert/9520689我从(与)Homebrew卸载节点并重新安装(仍然使用Homebrew)没有npm,然后单独安装npm,官方.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 :)

也就是说,你提到你有Linux,所以你的问题可能不是这样,但是这些信息可能会让你了解可能是什么情况或帮助他人,所以张贴以防万一:)

Good luck!

祝你好运!

#1


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.

我只是有完全相同的问题,甚至npm视图npm版本为我返回6.4.0但是npm -v仍然打印出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.

点击此链接:https://gist.github.com/DanHerbert/9520689我从(与)Homebrew卸载节点并重新安装(仍然使用Homebrew)没有npm,然后单独安装npm,官方.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 :)

也就是说,你提到你有Linux,所以你的问题可能不是这样,但是这些信息可能会让你了解可能是什么情况或帮助他人,所以张贴以防万一:)

Good luck!

祝你好运!