1

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

Leandro William
  • 457
  • 5
  • 12

4 Answers4

3

Try clearing the npm cache:

npm cache clean --force

then

npm i npm@6 -g

Hope it helps.

vitomadio
  • 1,140
  • 8
  • 14
1

To update nodejs itself you can use nvm, like so:

see available versions and version in use:

`nvm ls`

switch to Node.js version 6.4.1:

`nvm use 6.4.1`

switch to Node.js version 9.3.0(any version, this is just an example) :

`nvm use 9.3`

switch automatically to latest Node.js version:

nvm use node

switch to latest LTS Node.js version:

nvm use node --lts

for reference, see this article.

EDIT: Misread the question, initially, so please refer to This post

ana.arede
  • 698
  • 7
  • 12
0

This is an issue with WSL and npm default install folder permissions. Trying install node again from nodejs for ubuntu and you will get npm 6.*

Leandro William
  • 457
  • 5
  • 12
0

use nvm to manage your node version - here is how you install it through homebrew

uninstall existing node
brew uninstall --force node

brew update
brew install nvm

save this your classpath (.bash_profile)

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

nvm install 6 (this install node version 6 stable build) you could also do nvm install 8 or nvm install 10 (based on the version you like to keep)

then do

nvm use 6

to use a specific node version you could also do nvm use 10 or nvm use 8

if you like to fix this version globally on your -- add nvm use 6 to your .bash_profile

Pravin Bansal
  • 4,315
  • 1
  • 28
  • 19