1. nvm快速入门

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

1.1. 下载并配置

  • 下载安装脚本并运行
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  • NVM配置国内镜像
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
  • 刷新环境变量
source ~/.bash_profile
  • 检测是否安装成功
command -v nvm
  • 升级 nvm
(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

1.2. 基本用法

  • 下载最新版本
nvm install node
  • 下载指定版本
nvm install 8
  • 列出全部远程可用版本
nvm ls-remote

nvm ls available

  • 使用最新版本
nvm use node
  • 使用指定版本
nvm use 8
  • 列出已安装版本
nvm ls

1.3. npm 镜像

  • 临时使用
npm install gitbook -g --registry https://registry.npm.taobao.org
  • 永久使用
npm config set registry https://registry.npm.taobao.org
  • 恢复使用
npm config set registry https://registry.npmjs.org
  • 当前镜像
npm config get registry

1.4. fad

  • nvm is not compatible with the npm config "prefix" option: currently set to ""

1.5. 参考资料

作者: 雪之梦
链接: https://snowdreams1006.github.io/todo/nvm-quickstart.html
来源: 雪之梦
本文原创发布于「雪之梦」,转载请注明出处,谢谢合作!

https://snowdreams1006.github.io/snowdreams1006-wechat-open.png

results matching ""

    No results matching ""