Reputation: 1743
Trying to update/change to a specific NPM version on NVM installed via homebrew
(Would be very useful when beta testing, currently NPM v3.0.x)
Doing it out of NVM I ran npm install -g [email protected]
In NVM I update to the current latest node version via nvm install v0.12.7
but this comes bundled with npm v2.11.3
. Obviously as it is the latest stable version of NPM.
Is there a way to select/install which version of NPM you want to use in NVM?
Upvotes: 3
Views: 8093
Reputation: 1752
Step 1) Clear the npm cache:
sudo npm cache clean -f
Step 2) Install the node helper application called "n":
sudo npm install -g n
Step 3) Install the specific version that you want, eg: for v12.14.1:
sudo npm v12.14.1
Alternatively, to just update to the latest stable node version:
sudo n stable
Step 4) Confirm that you are running the desired version:
node -version
or
node -v
Reference: Code Geek: How to Update Node to Any Version using Npm
Upvotes: 0
Reputation: 119
In case you using nvm, node and npm ware installed as couple into the nodeVERSION directory. for example C:\Users\user\AppData\Roaming\nvm\v8.11.1
So in case that you want to upgrade npm version in specific node version all you need to to is: to copy dir node_modules/npm from the nodejs location, remove the npm bin and cmd, and run node npm-cli.js i -g npm@latest inside bin dir in the copied folder.
For understanding, in case you update npm using specific node version through nvm it'll be specific update of npm to the node version.
for instance: you have two versions of node: 1) v8.11.1 2) v9.8.0
In both of them npm version 5.8.0 installed.
In case you are using option 1 (version v8.11.1) and you want to upgrade npm version to npm 6.0.0 (using npm command npm i -g [email protected]) the upgrade will be only for node option 1 and not for option 2.
So remember in case you switch back to option 2 the npm version will be 5.8.0.
Upvotes: 2
Reputation: 1085
you just switch to the desired node version with nvm and then just execute:
npm install -g [email protected]
being 1.4.3 the desired npm version
to see different versions you can use:
npm view npm
Upvotes: 7