Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nvm-管理多版本

  • 下载安装

    • 如果装了brewhome:
      brew install nvm
      
    • 如果没装,就要用脚本
      curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | bash
      
  • 配置目录

    mkdir ~/.nvm
    
    • 要先确保装了zsh,然后在vim ~/.zshrc添加如下几行:
      export NVM_DIR="$HOME/.nvm"
      [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
      [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"
      
    • 添加完后,执行source ~/.zshrc使其生效
    • echo $NVM_DIR检查是否生效
  • 安装nodejs

    • 最新稳定版
    nvm install stable
    
    • 列出所有可安装版本
    nvm ls-remote
    
    • 指定版本
    nvm install <version> 
    
  • 常用指令

    • 列出本地已安装版本
    nvm ls
    
    • 切换版本
    nvm use <version>
    
    • 修改默认版本
    nvm alias default v14.xx.xx