jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.08k stars 69 forks source link

[Question] - Is there a way to update npm? #133

Closed wonbyte closed 3 years ago

wonbyte commented 3 years ago

Is there a way to update npm similiar to how nvm.sh does it i.e. nvm install-latest-npm? If not, is what's the best approach to do it?

jorgebucaran commented 3 years ago

@wonbyte Try:

npm install --global npm

Here's how that went for me:

$ nvm install 6
Installing Node v6.17.1 lts/boron
Fetching https://nodejs.org/dist/v6.17.1/node-v6.17.1-darwin-x64.tar.gz
Now using Node v6.17.1 (npm 3.10.10) ~/.local/share/nvm/v6.17.1/bin/node
$ npm --version
3.10.10
$ npm install --global npm
...
$ npm --version
6.14.11
wonbyte commented 3 years ago

@jorgebucaran I'm assuming this works bc nvm.fish has the --global pointing to the current node nvm environment? To be clear, I only want to update the npm that is associated with the corresponding active nvm environment.

jorgebucaran commented 3 years ago

I'm assuming this works bc nvm.fish has the --global pointing to the current node nvm environment?

Correct.

$ type npm
npm is /home/jb/.local/share/nvm/v6.17.1/bin/npm

To be clear, I only want to update the npm that is associated with the corresponding active nvm environment.

That's what it does. It replaces the npm bundled with the active Node, the one managed by nvm in this case.