安装NodeJs和NPM到Ubuntu(APT)

运行环境

系统版本:Ubuntu 16.04.2 LTS
软件版本:node-v10.16.3、npm-6.9.0
硬件要求:无

安装过程

1、安装NPM和NodeJs

root@localhost:~# apt-get update
root@localhost:~# apt-get -y install npm

2、配置NPM使用淘宝源

root@localhost:~# npm conf set registry https://registry.npm.taobao.org

3、升级NodeJs和NPM到最新版本

root@localhost:~# npm cache clean -f
root@localhost:~# npm i -g n stable
mkdir /usr/local/n/versions/node/10.16.3
root@localhost:~# npm install -g npm

4、配置环境变量

root@localhost:~# vim /etc/profile
export PATH=$PATH:/usr/local/n/versions/node/10.16.3/bin
root@localhost:~# source /etc/profile

5、查看NodeJs和NPM的版本

root@localhost:~# node -v
v10.16.3
root@localhost:~# npm -v
6.9.0
乐在分享!~~
原文地址:https://www.cnblogs.com/network-ren/p/12377786.html