首页 > 解决方案 > Problems upgrading npm version

问题描述

I was trying to upgrade npm version:

npm -v

5.6.0

sudo npm install -g npm@6

/home/${user}/.npm-global/bin/npm -> /home/${user}/.npm-global/lib/node_modules/npm/bin/npm-cli.js

/home/${user}/.npm-global/bin/npx -> /home/${user}/.npm-global/lib/node_modules/npm/bin/npx-cli.js

+ npm@6.4.1

updated 1 package in 20.723s

but still remain version of v5.6.0 after I checked with

npm -v

5.6.0

I'm using Windows 10 (version 1803) but I have nodejs installed on WSL running Ubuntu 18.04 Node was install following these steps

UPDATE:

It's seems a problem with oh-my-zsh… Because I tried from bash and the versions is correct (6.4.1) and from bash when I type zsh I get 6.4.1 npm version. But when I start the terminal, zsh don't load the correct npm version.

I'm loading oh-my-zsh with this way

~/.bashrc

bash -c zsh

标签: node.jsnpmwindows-subsystem-for-linux

解决方案


尝试清除 npm 缓存:

npm cache clean --force

然后

npm i npm@6 -g

希望能帮助到你。


推荐阅读