How can I change the version of npm using nvm?

后端 未结 14 2161
温柔的废话
温柔的废话 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:21

    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.

提交回复
热议问题