ubuntu16.04 安装node.js

1、更新ubuntu软件源
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
2、安装nodejs
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm
3、更新npm的包镜像源,方便快速下载
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
4、全局安装n管理器(用于管理nodejs版本)
sudo npm install n -g
5、安装最新的nodejs(stable版本)
sudo n stable
6、升级npm为最新版本
sudo npm install npm@latest -g
7、查看版本
sudo node -v
sudo npm -v

猜你喜欢

转载自blog.51cto.com/xiaok007/2335337