配置更新源
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
添加 nodejs 更新源
sudo curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
更新系统,并安装编译包
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y build-essential
安装Node.js,同时会自动安装npm
$ sudo apt-get install -y nodejs
更新node/npm/npx
$ sudo npx dist-upgrade
如果发生错误
sudo npm cache verify
sudo npm cache clean --force
更换淘宝源码
sudo npm --registry http://registry.npm.taobao.org/ i -g nrm
nrm use taobao
sudo npx dist-upgrade