I cannot seem to update npm with npm install:
$ npm -v
5.6.0
$ sudo npm install -g npm@latest
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.7.1
updated 1 package in 11.905s
$ npm -v
5.6.0
What's the output of your which npm
, I bet it is not /usr/bin/npm
.
UPDATE :
So yours' at /usr/local/bin/npm
, but the npm
you just updated is at /usr/bin/npm
. See the line /usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
for the hint.
Remove the installation at /usr/local/bin/npm
and you'll be fine.
If you don't know how to do that, simply do
sudo rm /usr/local/bin/npm
I had noted that after installing the update, I have the re-login to the shell too see the updated npm version. Not sure why some ppl don't have to do this, but in my case, that's what I had to do.
使用hash -r
使bash清除其缓存并再次查看路径以获取最新的npm路径。
I had the same prob,
npm will always use the version of npm installed with node. If you are running node update node first running:
Good luck!:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.