How can I change the version of npm using nvm?

后端 未结 14 2159
温柔的废话
温柔的废话 2020-11-28 17:27

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

14条回答
  •  执笔经年
    2020-11-28 18:22

    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.

提交回复
热议问题