node安装
安装nvm
- 直接安装
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
- 上面两种方式直接可以安装好,如果安装出问题,请使用下面的方法
git clone https://github.com/creationix/nvm.git
下载nvm的源码,这个可以直接使用,记得在
~
目录下载
mv nvm .nvm
修改文件夹名称
在 ~/.bashrc, ~/.bash_profile, ~/.profile, 或者 ~/.zshrc 文件添加以下命令:
source ~/git/nvm/nvm.sh
- 退出重新进入一下终端
nvm --version
返回版本号说明安装成功
使用nvm安装node
- 安装
nvm version-remote --lts
获取最新稳定发行版
nvm install v12.16.2
不出意外应该安装成功
nvm use v12.16.2
- 查看版本号
node -v
npm -v
都成功返回版本号,则安装成功
nvm在terminal每次启动都要重新设置use
nvm alias default stable
设置npm
设置淘宝镜像
npm config set registry https://registry.npm.taobao.org
验证是否成功
npm config get registry