克隆nvm镜像
git clone https://gitee.com/mirrors/nvm
安装nvm
bash install.sh # 注意:进入nvm目录内执行
问题:Command ‘nvm’ not found
安装完成后会提示:Command ‘nvm’ not found, but there are 13 similar ones.
我们按照安装完成后的提示:Close and reopen your terminal to start using nvm。
会发现并没有什么效果。
然后我继续尝试了第二种方案:
run the following to use it now:
export NVM_DIR=“
H
O
M
E
/
.
n
v
m
"
[
−
s
"
HOME/.nvm" [ -s "
HOME/.nvm"[−s"NVM_DIR/nvm.sh” ] && . “KaTeX parse error: Expected 'EOF', got '#' at position 18: …M_DIR/nvm.sh" #̲ This loads nvm…NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion
如果上述步骤执行还有问题,可以先执行。
touch ~/.bash_profile
然后再重复上述安装操作即可。
检查是否安装成功
nvm --version
安装node
nvm ls-remote # 查看可安装的版本
nvm install 8.12.0 # 安装指定版本,如8.12.0
nvm ls # 查看已安装的node版本
nvm use 8.12.0 # 使用指定的版本,如8.12.0
nvm uninstall 8.12.0 # 卸载指定版本,如8.12.0
使用npm
npm -V # 查看npm版本
npm install -g npm # 更新最新版本
npm install -h npm@5.6.0 # 更到指定版本
npm config ls # 查npm配置
npm config ls -l #查看npm全部配置
npm config set registry "http://registry.npm.taobao.org/" # 修改npm为国内镜像