不要再改host了,改host只是改了DNS,不代表你能连上那个IP。
其实nvm的github中说的很清楚了,可以使用git方式安装:
Git Install
If you have git
installed (requires git v1.7.10+):
- clone this repo in the root of your user profile
cd ~/
from anywhere thengit clone https://github.com/nvm-sh/nvm.git .nvm
cd ~/.nvm
and check out the latest version withgit checkout v0.39.0
- activate
nvm
by sourcing it from your shell:. ./nvm.sh
Now add these lines to your ~/.bashrc
, ~/.profile
, or ~/.zshrc
file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
如果直接从github太慢的话,可以先在gitee上注册一个账户,然后登录gitee并选择”从Github导入仓库“。
然后用下面的命令拉到ubuntu的home下:
cd ~
git clone https://gitee.com/[你的gitee仓库链接].git .nvm
添加taobao镜像:
参考:https://www.jianshu.com/p/dbc4db1eb608
echo -e "\nexport NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node" >> ~/.bashrc
source ~/.bashrc