1.首先对apt包管理工具更新
sudo apt-get update
2.卸载原有的nodejs
sudo apt-get remove nodejs --purge
3.安装node
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs
4.查看版本
node -v
npm -v
5.安装pm2
npm install pm2 -g
pm2 -v
6.网上还有在线升级nodejs的方案
安装node的版本管理工具
npm install -g n
n latest
n stable