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 ...
随机推荐
- html5(四) canvas
http://www.cnblogs.com/Gyoung/archive/2013/04/08/2994515.html
- 用Apache Ant在Weka中嵌入新算法
本文将介绍一种新的添加新的算法到Weka中的方法,国内的论坛基本都是通过IDE(Eclipse或NetBeans)编译,详细教程请见上一篇博客.经研究,发现国外的网站很流行用Ant这个方法,教程奉上. ...
- java虚拟机之虚拟机类加载机制
此处主要需要知道什么是java虚拟机?java虚拟机如何进行类加载的? java语言本身是编译型和解释型的语言,先对本地的java文件进行编译,编译后会在本地生成一个class文件,而这个生成的cla ...
- gcc4.9.1新特性
C family Support for colorizing diagnostics emitted by GCC has been added. The -fdiagnostics-color=a ...
- day20_python_1124
01 昨日内容回顾 类的名称空间 对象的空间 class A: def __init__(): pass obj = A() 对象查询属性:对象本身 ----> 类 -----> 父类 类 ...
- javascript接口注释法
//注释法//简单,功能弱 利用 大型的项目靠得是规范和标准 有充分时间 缺点:人为的遵守/** interface personDao{* function add(obj);* function ...
- LeetCode Rotatelmage
---恢复内容开始--- You are given an n x n 2D matrix representing an image. Ratate the image by 90 degrees( ...
- 阶段01Java基础day18集合框架04
18.01_集合框架(Map集合概述和特点) A:Map接口概述 查看API可以知道: 将键映射到值的对象 一个映射不能包含重复的键 每个键最多只能映射到一个值 B:Map接口和Collection接 ...
- GraphHttpClient概述
博客地址:http://blog.csdn.net/FoxDave 目前这个东西还在预览阶段,所以不推荐在正式生产环境中使用. 我们可以使用Microsoft Graph接口来构建强大的解决方案来访问 ...
- 利用htmlparser读取html文档的内容
1.添加相关的的jar htmlparser-2.1.jar 2.方法和代码 public static String readHtml(File html) { String htmlPath = ...