安装最新版nodejs

更新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() 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相关文件:/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

Q: node -v异常

node -v
-bash: /usr/local/bin/node: Permission denied sudo node -v
Segmentation fault (core dumped) // A: 重新安装nodejs
手动移除 /usr/local/lib/node_modules整个目录
手动移除 /usr/local/bin/node
手动移除 /usr/local/bin/n
手动移除 /usr/local/bin/npm

ubuntu软件源

修改/etc/apt/sources.list为以下软件源(改前请备份)
163和里面在部分网络下会一直下载失败,可以改回官方源下载

源列表

http://wiki.ubuntu.org.cn/模板:16.04source

Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse

小礼物走一走,来简书关注我

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

【转载】Ubuntu16.04安装最新版nodejs的更多相关文章

  1. ubuntu16.04 安装最新版nodejs

    ubuntu软件仓库中自带的nodejs版本过低 $ apt-cache policy nodejs nodejs: Installed: (none) Candidate: 4.2.6~dfsg-1 ...

  2. Ubuntu16.04安装最新版nodejs

    原文链接:https://www.jianshu.com/p/2b24cd430a7d

  3. ubuntu16.04安装最新版docker、docker-compose、docker-machine

    安装前说明: 本文将介绍在ubuntu16.04系统下安装和升级docker.docker-compose.docker-machine. docker:有两个版本:docker-ce(社区版)和do ...

  4. Ubuntu16.04安装后开发环境配置和常用软件安装

    Ubuntu16.04安装后1.安装常用软件搜狗输入法+编辑器Atom+浏览器Chome+视频播放器vlc+图像编辑器GIMP Image Editor安装+视频录制软件RcordMyDesktop安 ...

  5. ubuntu16.04安装node.js、npm

    ubuntu16.04安装node.js.npm1.请尽量避免在 Ubuntu 上使用 apt-get 来安装 node.js, 如果你已经这么做了,请手动移除: sudo apt-get purge ...

  6. Ubuntu16.04安装TensorFlow及Mnist训练

    版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com TensorFlow是Google开发的开源的深度学习框架,也是当前使用最广泛的深度学习框架. 一.安 ...

  7. Ubuntu16.04安装Ambari 2.7.3

    概念了解 Ambair介绍 Apache Ambari是一个用于支持大数据软件供应 管理与监控软件.它也是一个分布式软件,分为Ambair-Server与Ambari-Client两个部分.在生产环境 ...

  8. Ubuntu16.04安装之后的几个设置

    Ubuntu16.04安装之后的几个设置 Ubuntu16.04界面很漂亮,但是安装之后,需要做如下几个简单的设置,这样用的时候会更加顺畅. 1.中文支持 在右上角有一个齿轮,点击->Syste ...

  9. 【转】ubuntu16.04安装Vivado 2017.4 教程

    ubuntu16.04安装Vivado 2017.4 教程 2017-12-28 20:59:48 wmyan 阅读数 11794   版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协 ...

随机推荐

  1. AtCoder Beginner Contest 104

    A - Rated for Me Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement A ...

  2. AtCoder Grand Contest #026 B - rng_10s

    Time Limit: 2 sec / Memory Limit: 1024 MB Score : 600600 points Problem Statement Ringo Mart, a conv ...

  3. ACM学习历程—BestCoder 2015百度之星资格赛1004 放盘子(策略 && 计算几何)

    Problem Description 小度熊喜欢恶作剧.今天他向来访者们提出一个恶俗的游戏.他和来访者们轮流往一个正多边形内放盘子.最后放盘子的是获胜者,会赢得失败者的一个吻.玩了两次以后,小度熊发 ...

  4. Codeforces 762C Two strings 字符串

    Cpdeforces 762C 题目大意: 给定两个字符串a,b\((len \leq 10^5)\),让你去b中的一个连续的字段,使剩余的b串中的拼接起来的两个串是a穿的子序列.最大化这个字串的长度 ...

  5. 【Opencv】Mat基础

    1.Mat::imread() C++: Mat imread(const string& filename, int flags=1 ) filename – Name of file to ...

  6. C++ STL std::wstring_convert处理UTF8

    #include <iostream> #include <string> #include <locale> #include <codecvt> # ...

  7. 用PCA降维 (Principal Component Analysis,主成分分析)

    参考资料:Mastering Machine Learning With scikit-learn 降维致力于解决三类问题.第一,降维可以缓解维度灾难问题.第二,降维可以在压缩数据的同时让信息损失最 ...

  8. 用nexus搭建自己的maven私有仓库

    用nexus搭建自己的maven私有仓库  刚安装nexus时,nexus启动失败,启动不到1分钟,自动停止.后来查找到了原因: Java 6 Support EOLOracle's support ...

  9. PHP调用Python快速发送高并发邮件

    1 简介 在PHP中发送邮件,通常都是封装一个php的smtp邮件类来发送邮件.但是PHP底层的socket编程相对于Python来说效率是非常低的.CleverCode同时写过用python写的爬虫 ...

  10. Lagom学习 五 Hello world工程

    用Maven创建一个Hello world的Lagom工程: 1: 在想创建工程的目下下,打开CMD 2:  mvn archetype:generate -Dfilter=com.lightbend ...