【Ubuntu】在Ubuntu16上安装nodejs以及npm

转载:

https://www.jianshu.com/p/2b24cd430a7d

步骤:

更新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

安装nodejs

sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm

更新npm的包镜像源,方便快速下载

sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list

全局安装n管理器(用于管理nodejs版本)

sudo npm install n -g

安装最新的nodejs(stable版本)

sudo n stable
sudo node -v

QA

Q: apt-get update找不到文件

// error code 
W: The repository 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. 
N: See apt-secure(8) manpage for repository creation and user configuration details. 
E: Failed to fetch http://ppa.launchpad.net/chris-lea/node.js/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found 
E: Some index files failed to download. They have been ignored, or old ones used instead. 

// A: 修改node相关文件:sudo gedit /etc/apt/sources.list.d/chris-lea-ubuntu-node_js-xenial.list 

deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu trusty main 
deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu trusty main

转自简书:

作者:十戒s
链接:https://www.jianshu.com/p/2b24cd430a7d
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值