美文网首页
nvm安装(mac端)

nvm安装(mac端)

作者: LL天HH土 | 来源:发表于2022-08-05 21:31 被阅读0次
    一、卸载掉电脑上的node(如果没有,请到下一步)

    mac卸载node,参考https://www.jianshu.com/p/88cd55296983

    如果可以访问github,请查看官网教程

    二、输入如下命令安装
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
    

    三、验证

    打开终端,输入

    command -v nvm
    

    如果输出nvm,则成功,否则,不成功(可参考原文教程)

    问题
    nvm使用教程
    $ nvm use 16
    Now using node v16.9.1 (npm v7.21.1)
    $ node -v
    v16.9.1
    $ nvm use 14
    Now using node v14.18.0 (npm v6.14.15)
    $ node -v
    v14.18.0
    $ nvm install 12
    Now using node v12.22.6 (npm v6.14.5)
    $ node -v
    v12.22.6
    
    nvm run 6.10.3 app.js                 Run app.js using node 6.10.3
    nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing to node 4.8.3
    nvm alias default 8.1.0               Set default node version on a shell
    nvm alias default node                Always default to the latest available node version on a shell
    
    nvm install node                      Install the latest available version
    nvm use node                          Use the latest version
    nvm install --lts                     Install the latest LTS version
    nvm use --lts                         Use the latest LTS version
    
    nvm set-colors cgYmW                  Set text colors to cyan, green, bold yellow, magenta, and white
    

    更换nvm

    1. 打开终端
    2. 输入open ~/.zshrc
    3. 在打开的文本编辑器里面,最下面添加下述代码
    export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
    

    解决nvm切换node版本后,重新打开终端失效

    使用nvm alias default 18来切换

    参考:
    https://github.com/nvm-sh/nvm#troubleshooting-on-macos

    相关文章

      网友评论

          本文标题:nvm安装(mac端)

          本文链接:https://www.haomeiwen.com/subject/kyqpbrtx.html