在nvm环境下安装nodejs、npm和yarn
安装nvm
1 | # wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash |
or
1 | # curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash |
.bashrc中已经自动添加,在不退出当前终端的情况下用下面的命令设置环境变量:
1 | # export NVM_DIR="$HOME/.nvm" |
安装nodejs和npm
1 | # nvm ls-remote --lts |
从列出的远程lts版本中选择最新的一个。
1 | # nvm install 8.11.3 |
升级npm:
1 | # npm i -g npm |
安装Yarn
1 | # curl -o- -L https://yarnpkg.com/install.sh | bash |
将$HOME/.yarn/bin路径添加到.bashrc或者.bash_profile的PATH环境变量中。
清理cache
1 | # nvm cache clear |
Done.