环境初始化#
Windows#
# Windows nvm-setup 安装版会默认设置环境变量
https://github.com/coreybutler/nvm-windows/releases
# 免安装版设置Windows配置环境变量
NVM_HOME=C:\developer\env\nvm
NVM_SYMLINK=C:\developer\env\nodejs
# PATH添加
%NVM_HOME%
%NVM_SYMLINK%
# nvm的镜像配置%NVM_HOME%\settins.txt
node_mirror: https://npmmirror.com/mirrors/node
npm_mirror: https://npmmirror.com/mirrors/npm
# 离线下载nodejs
https://nodejs.org/en/download/releases/
# Windows的Nodejs位置
%NVM_HOME%\v20.5.1
Linux#
# Linux 在线
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# Linux 离线安装
git clone https://github.com/nvm-sh/nvm.git .nvm
git checkout v0.39.5
. ./nvm.sh
# 编辑启动配置~/.bashrc ~/.profile ~/.zshrc
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
export NVM_IOJS_ORG_MIRROR=https://npmmirror.com/mirrors/npm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Linux的Nodejs位置
$NVM_DIR/versions/node/v20.5.1
命令行#
# Linux使用https的镜像源会有证书问题,在~/.curlrc写个-k,跳过https证书检查
vim ~/.curlrc
-k
nvm -v
nvm list available
nvm ls-remote
nvm install 16.0.0
nvm use 16.0.0
...