ubuntu16.04 安装最新版nodejs
- ubuntu软件仓库中自带的nodejs版本过低
$ apt-cache policy nodejs
nodejs:
Installed: (none)
Candidate: 4.2.6~dfsg-1ubuntu4.2
Version table:
4.2.6~dfsg-1ubuntu4.2 500
500 http://mirrors.aliyun.com/ubuntu xenial-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages
4.2.6~dfsg-1ubuntu4 500
500 http://mirrors.aliyun.com/ubuntu xenial/universe amd64 Packages
- 要安装高版本需要使用新的镜像源
但国内访问deb.nodesource.com会出现连接超时,需要设置代理
测试结果如下:
$ curl -sL -v https://deb.nodesource.com/setup_8.x
* Trying 13.35.8.34...
* Connected to deb.nodesource.com (13.35.8.34) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 592 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* gnutls_handshake() failed: The TLS connection was non-properly terminated.
* Closing connection 0
Step1> 设置代理
以socks5代理为例:
$ export http_proxy=socks5://127.0.0.1:1080
$ export HTTPS_PROXY=socks5://127.0.0.1:1080
Step2> 使用脚本进行安装:
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install nodejs
安装记录
## Confirming "xenial" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_8.x/dists/xenial/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js 8.x LTS Carbon repo...
+ echo 'deb https://deb.nodesource.com/node_8.x xenial main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Hit:5 http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial InRelease
Get:6 https://deb.nodesource.com/node_8.x xenial InRelease [4,646 B]
Get:7 https://deb.nodesource.com/node_8.x xenial/main Sources [761 B]
Get:8 https://deb.nodesource.com/node_8.x xenial/main amd64 Packages [1,006 B]
Get:9 https://deb.nodesource.com/node_8.x xenial/main i386 Packages [1,004 B]
Fetched 7,417 B in 1s (5,551 B/s)
Reading package lists... Done
## Run `sudo apt-get install -y nodejs` to install Node.js 8.x LTS Carbon and npm
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
如果不想使用脚本,也可以选择手动安装,过程如下:
$ sudo apt-get install apt-transport-https
# 使用代理下载nodesource.gpg.key
$ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
OK
# 使用清华镜像源
$ sudo bash -c "echo \"deb https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_8.x xenial main\" > /etc/apt/sources.list.d/nodesource.list"
$ sudo bash -c "echo \"deb-src https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_8.x/ xenial main\" >> /etc/apt/sources.list.d/nodesource.list"
$ cat /etc/apt/sources.list.d/nodesource.list
deb https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_8.x xenial main
deb-src https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_8.x/ xenial main
$ sudo apt-get update
$ sudo apt-get install nodejs
nodejs安装核心步骤

key相关操作
$ apt-key list
...
pub 4096R/68576280 2014-06-13
uid NodeSource <gpg@nodesource.com>
sub 4096R/AA01DA2C 2014-06-13
...
$sudo apt-key del 68576280
$apt-key list | grep node
参考:
- https://nodejs.org/zh-cn/download/package-manager/
- https://mirror.tuna.tsinghua.edu.cn/help/nodesource/
ubuntu16.04 安装最新版nodejs的更多相关文章
- 【转载】Ubuntu16.04安装最新版nodejs
安装最新版nodejs 更新ubuntu软件源 sudo apt-get update sudo apt-get install -y python-software-properties softw ...
- Ubuntu16.04安装最新版nodejs
原文链接:https://www.jianshu.com/p/2b24cd430a7d
- ubuntu16.04安装最新版docker、docker-compose、docker-machine
安装前说明: 本文将介绍在ubuntu16.04系统下安装和升级docker.docker-compose.docker-machine. docker:有两个版本:docker-ce(社区版)和do ...
- Ubuntu16.04安装后开发环境配置和常用软件安装
Ubuntu16.04安装后1.安装常用软件搜狗输入法+编辑器Atom+浏览器Chome+视频播放器vlc+图像编辑器GIMP Image Editor安装+视频录制软件RcordMyDesktop安 ...
- Ubuntu16.04安装Ambari 2.7.3
概念了解 Ambair介绍 Apache Ambari是一个用于支持大数据软件供应 管理与监控软件.它也是一个分布式软件,分为Ambair-Server与Ambari-Client两个部分.在生产环境 ...
- Ubuntu16.04安装之后的几个设置
Ubuntu16.04安装之后的几个设置 Ubuntu16.04界面很漂亮,但是安装之后,需要做如下几个简单的设置,这样用的时候会更加顺畅. 1.中文支持 在右上角有一个齿轮,点击->Syste ...
- ubuntu16.04安装node.js、npm
ubuntu16.04安装node.js.npm1.请尽量避免在 Ubuntu 上使用 apt-get 来安装 node.js, 如果你已经这么做了,请手动移除: sudo apt-get purge ...
- ubuntu16.04安装jdk,tomcat
ubuntu16.04安装jdk,tomcat 最近装了一下tomcat,网上的教程很多,我也试了很多次,但是有一些教程关于tomcat配置是错误的,让我走上了歧途.差点重装系统,还好王总及时出手帮助 ...
- Ubuntu16.04 安装openjdk-7-jdk
Ubuntu16.04 安装openjdk-7-jdk sudo apt-get install openjdk-7-jre 或者sudo apt-get install openjdk-7-jdk ...
随机推荐
- spring cloud(二)服务(注册)中心Eureka
Eureka是Netflix开源的一款提供服务注册和发现的产品,它提供了完整的Service Registry和Service Discovery实现.也是springcloud体系中最重要最核心的组 ...
- sublim 配置 用户默认绑定的格式化文本快捷键
//在绑定用户绑定配置中 加入 激活每个字母提示! "auto_complete": true,"auto_match_enabled": true, &q ...
- 使用npm install时一直报错-4048 operation not permitted
一:权限问题 首先看到operation not permitted我们能想到权限问题,所以这时候我们可以以管理员身份运行cmd或者直接快捷键Win+X来打开. 二:依赖包错误 如上图,根据错误日志我 ...
- web前端性能优化总结一
转自:http://www.2cto.com/kf/201604/498725.html 网站的划分一般为二:前端和后台.我们可以理解成后台是用来实现网站的功能的,比如:实现用户注册,用户能够为文章发 ...
- Unity调试模式设置辅助线是否可见
1.新建变量 //调试的标识(状态开关) public bool m_debug = true; 2.在画线方法中写 //如果非调试状态,则不再输出网格和立方体 if (!m_debug) { ret ...
- tomcat的LifecycleException异常
异常:start: org.apache.catalina.LifecycleException: tomcat版本:8 解决:将tomcat的版本换成tomcat6,问题解决了
- 编译darknet出现libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’未定义的引用
cd /usr/lib/x86_64-linux-gnu sudo ln -s ~/anaconda/lib/libpng16.so.16 libpng16.so.16 sudo ldconfig## ...
- alias-unalias
一.用一条命令完成创建目录/data/test,即在/目录下创建/data目录,及其子目录/data/test 解答:mkdir -p /data/test 实践过程: 二.已知/tmp目录下已经存在 ...
- python day27--常用模块 time,random,os,序列化
一.time模块 %y 两位数的年份表示(00-99) %Y 四位数的年份表示(000-9999) %m 月份(01-12) %d 月内中的一天(0-31) %H 24小时制小时数(0-23) %I ...
- 自动化测试-2.seleniumIDE
一.安装步骤 1. 打开Firefox浏览器 2. 打开https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/versions/,点击 ...