I\'ve been using NVM to install the latest versions of nodeJS for my node work. It works totally fine for installing separate versions and switching between them. It also in
Slight variation on the above instructions, worked for me. (MacOS Sierra 10.12.6)
npm install -g npm@3.10.10
rm /usr/local/bin/npm
ln -s ~/.npm-packages/bin/npm /usr/local/bin/npm
npm --version
npm install npm@x.x.x -g
npm install npm@5.4.0 -g
I'm on Windows and I couldn't get any of this stuff to work. I kept getting errors about files being in the way. This worked though:
cd %APPDATA%\nvm\v8.10.0 # or whatever version you're using
mv npm npm-old
mv npm.cmd npm-old.cmd
cd node_modules\
mv npm npm-old
cd npm-old\bin
node npm-cli.js i -g npm@latest
cd %APPDATA%\nvm\v8.10.0 # or whatever version you're using
rm npm-old
rm npm-old.cmd
cd node_modules\
rm -rf npm-old
And boom, I'm back in business.
nvm doesn't handle npm.
So if you want to install node 0.4.x (which many packages still depend on) and use NPM, you can still use npm 1.0.x.
Install node 0.6.x (which comes with npm 1.1.x) and install nvm with npm:
npm install nvm
. ~/nvm/nvm.sh
Install node 0.4.x with nvm:
nvm install v0.4.12
nvm use v0.4.12
Install npm using install.sh (note the -L
param to follow any redirects):
curl -L https://npmjs.org/install.sh | sh
This will detect node 0.4.12 and install npm 1.0.106 in your ~/nvm/v0.4.12/lib/node_modules folder and create symlink for nvm
~/nvm/v0.4.12/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
If you try to run npm, it will still give an error but if you do nvm use v0.4.12
again, it should now work.
The easy way to change version is first to check your available version using nvm ls then select version from the list nvm use version
What about npm i -g npm
? Did you try to run this as well?