经过几天的尝试,终于装好了:

1. nodejs官方推荐一下安装方式:

NodeSource的二进制安装脚本NodeSource

Using Ubuntu

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install nodejs-legacy

试了,不行,然后terminal提示我用:apt install nodejs

2. nvm 切换用户的话,安装好的node,就不见了

3. 最后使用Ubuntu提示的方式安装:

apt install nodejs
apt all npm

成功安装,但是版本很老,
node4.2.6
npm -v 3.2

终于发现了一个可以管理node版本的第三方库,n来自tj大神。
安装n有几种方式,最快捷的是用npm安装,前面的安装已经为这里打好了铺垫,现在只需要运行npm install -g n,安装好后升级nodejsn latest

Use or install the latest official release:

$ n latest

Use or install the stable official release:

$ n stable

If you are looking for NodeSource's Enterprise-grade Node.js platform,N|Solid,please visit https://downloads.nodesource.com/

For Debian / Ubuntu based distributions,see the deb directory for the source of the two setup scripts located at https://deb.nodesource.com/setup and https://deb.nodesource.com/setup_dev.

For Enterprise Linux based distributions (Red Hat® Enterprise Linux® / RHEL,CentOS,CloudLinux,Fedora),see the rpm directory for the source of setup script located at https://rpm.nodesource.com/setup.

Please file an issue if you are experiencing a problem or would like to discuss something related to the distributions.

Pull requests are encouraged if you have changes you believe would improve the setup process or increase compatibility across Linux distributions.

  • Debian and Ubuntu based distributions (deb)
    • Installation instructions
    • Manual installation
  • Enterprise Linux based distributions (rpm)
    • Installation instructions
  • Tests

Debian and Ubuntu based distributions

Available architectures:

NodeSource will continue to maintain the following architectures and may add additional ones in the future.

  • i386 (32-bit)
  • amd64 (64-bit)
  • armhf (ARM 32-bit hard-float,ARMv7 and up: arm-linux-gnueabihf)

PLEASE NOTE that armhf builds AND builds >= v7.x are NOT available for Debian Wheezy or Ubuntu Precise. For more information read about Node.JS >= 4.x on older distros.

Supported Ubuntu versions:

NodeSource will maintain Ubuntu distributions in active support by Canonical,including LTS and the intermediate releases.

  • Ubuntu 12.04 LTS (Precise Pangolin)
  • Ubuntu 14.04 LTS (Trusty Tahr)
  • Ubuntu 16.04 LTS (Xenial Xerus)
  • Ubuntu 16.10 (Yakkety Yak) [Node 0.10.x and 0.12.x not supported]

Supported Debian versions:

NodeSource will maintain support for stable,testing and unstable releases of Debian,due to the long release cycle a considerable number of users are running unstable.

  • Debian 7 (wheezy)
  • Debian 8 / stable (jessie)
  • Debian testing (stretch,aliased to jessie)
  • Debian unstable (sid)

Supported Linux Mint versions:

  • Linux Mint 13 "Maya" (via Ubuntu 12.04 LTS)
  • Linux Mint 17 "Qiana" (via Ubuntu 14.04 LTS)
  • Linux Mint 17.1 "Rebecca" (via Ubuntu 14.04 LTS)
  • Linux Mint 17.2 "Rafaela" (via Ubuntu 14.04 LTS)
  • Linux Mint Debian Edition (LMDE) 2 "Betsy" (via Debian 8)

Supported elementary OS versions:

  • elementary OS Luna (via Ubuntu 12.04 LTS)
  • elementary OS Freya (via Ubuntu 14.04 LTS)
  • elementary OS Loki (via Ubuntu 16.04)

Supported Trisquel versions:

  • Trisquel 6 "Toutatis" (via Ubuntu 12.04 LTS)
  • Trisquel 7 "Belenos" (via Ubuntu 14.04 LTS)

Supported BOSS versions:

  • BOSS 5.0 "Anokha" (via Debian 7)

Supported BunsenLabs versions:

  • Hydrogen (rc2) (via Debian 8)

Installation instructions

Node.js v7.x:

  • NOTE: Debian Wheezy and Ubuntu Precise packages are NOT available for this release. Please reference running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_7.x | bash -
apt-get install -y nodejs

Node.js v6.x:

  • NOTE: If you are using Ubuntu Precise or Debian Wheezy,you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs

Node.js v5.x:

  • NOTE: If you are using Ubuntu Precise or Debian Wheezy,you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs

Node.js v4.x:

  • NOTE: If you are using Ubuntu Precise or Debian Wheezy,you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs

Node.js v0.12:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_0.12 | bash -
apt-get install -y nodejs

Node.js v0.10:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs

io.js v3.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_3.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_iojs_3.x | bash -
apt-get install -y iojs

io.js v2.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_2.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_iojs_2.x | bash -
apt-get install -y iojs

io.js v1.x:

Note: this branch of io.js is not actively maintained and is not recommended for production use.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_iojs_1.x | sudo -E bash -
sudo apt-get install -y iojs

# Using Debian,as root
curl -sL https://deb.nodesource.com/setup_iojs_1.x | bash -
apt-get install -y iojs

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

# use `sudo` on Ubuntu or run this as root on debian
apt-get install -y build-essential

Manual installation

If you're not a fan of curl <url> | bash -,or are using an unsupported distribution,you can try a manual installation.

These instructions assume sudo is present,however some distributions do not include this command by default,particularly those focused on a minimal environment. In this case,you should install sudo or su to root to run the commands directly.

1. Remove the old PPA if it exists

This step is only required if you prevIoUsly used Chris Lea's Node.js PPA.

# add-apt-repository may not be present on some Ubuntu releases:
#sudo apt-get install python-software-properties
sudo add-apt-repository -y -r ppa:chris-lea/node.js
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save

2. Add the NodeSource package signing key

curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
# wget can also be used:
# wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

3. Add the desired NodeSource repository

# Replace with the branch of Node.js or io.js you want to install: node_0.10,node_0.12,node_4.x,node_5.x,etc...
VERSION=node_5.x
# The below command will set this correctly,but if lsb_release isn't available,you can set it manually:
# - For Debian distributions: wheezey,jessie,sid,etc...
# - For Ubuntu distributions: precise,trusty,xenial,etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
disTRO="$(lsb_release -s -c)"
echo "deb https://deb.nodesource.com/$VERSION $disTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/$VERSION $disTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

4. Update package lists and install Node.js

sudo apt-get update
sudo apt-get install nodejs

Enterprise Linux based distributions

Available architectures:

NodeSource will continue to maintain the following architectures and may add additional ones in the future.

  • i386 (32-bit,not available for all distros)
  • x86_64 (64-bit)

Supported Red Hat® Enterprise Linux® versions:

  • RHEL 5 (32-bit and 64-bit) [For Node < 0.12.x]
  • RHEL 6 (32-bit and 64-bit) [For Node < 4.x]
  • RHEL 6 (64-bit) [For Node >= 4.x]
  • RHEL 7 (64-bit)

Supported CentOS versions:

  • CentOS 5 (32-bit and 64-bit) [For Node < 0.12.x]
  • CentOS 6 (32-bit and 64-bit) [For Node < 4.x]
  • CentOS 6 (64-bit) [For Node >= 4.x]
  • CentOS 7 (64-bit)

Supported CloudLinux versions:

  • CloudLinux 6 (32-bit and 64-bit)

Supported Fedora versions:

  • Fedora 24 (Twenty Four) (32-bit and 64-bit) [For Node >= 4.4.6]
  • Fedora 23 (Twenty Three) (32-bit and 64-bit) [For Node >= 4.2.x]

Equivalent versions of Korora Linux should also be supported.

Installation instructions

Current instructions for installing,as listed on the Node.js Wiki:

Note that the Node.js packages for EL 5 (RHEL5 and CentOS 5) depend on the EPEL repository being available. The setup script will check and provide instructions if it is not installed.

Run as root on RHEL,CloudLinux or Fedora:

NodeJS 7.x

  • NOTE: If you are using RHEL 6 or CentOS 6,you might want to read about running Node.js >= 4.x on older distros.
curl -sL https://rpm.nodesource.com/setup_7.x | bash -

NodeJS 6.x

  • NOTE: If you are using RHEL 6 or CentOS 6,you might want to read about running Node.js >= 4.x on older distros.
curl -sL https://rpm.nodesource.com/setup_6.x | bash -

NodeJS 5.x

  • NOTE: If you are using RHEL 6 or CentOS 6,you might want to read about running Node.js >= 4.x on older distros.
curl -sL https://rpm.nodesource.com/setup_5.x | bash -

NodeJS 4.x

  • NOTE: If you are using RHEL 6 or CentOS 6,you might want to read about running Node.js >= 4.x on older distros.
curl -sL https://rpm.nodesource.com/setup_4.x | bash -

NodeJS 0.12.x

curl -sL https://rpm.nodesource.com/setup_0.12 | bash -

NodeJS 0.10.x

curl -sL https://rpm.nodesource.com/setup | bash -

Then install,as root:

yum install -y nodejs

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

yum install gcc-c++ make
# or: yum groupinstall 'Development Tools'

Tests

To test an installation is working (and that the setup scripts are working!) use:

curl -sL https://deb.nodesource.com/test | bash -

FAQ

Q: How do I use this repo when behind a proxy?

A: Please take a look at issue #9

Q: How do I pin to specific versions of Node.js?

A: Please take a look at issue #33

Q: I upgraded to a new major version of Node.js using the scripts,but the old version is still being installed,what is going on?

A: You probably need to clear out your package manager's cache. Take a look at issue #191

Q: I'm trying to install Node.js on Centos 5 and it is failing,why?

A: Do to the limitations of the compiler tool chain on Centos5,we currently can only support Node.js 0.10 on that release. See issue #190

Q: I'm seeing "Your distribution,identified as ".i686" or ".i386,is not currently supported,why?

A: Node.js 4.x and newer require a 64bit os for rpms. See issue #268

Q: Why have certain versions of platforms/releases stopped receiving updates to Node.js?

A: Unfortunately,newer versions of v8 require a modern compiler toolchain. On some platforms,such as ARM wheezy,that toolchain is not available. See issue #247

Q: What is the current status of IPv6 support?

A: See issue #170

Requested distributions

We,unfortunately,do not have the resources necessary to support and test the plethora of Linux releases in the wild,so we rely on community members such as yourself to get support on your favorite distributions! This is a list of releases that have been requested by the community. If you are interested in contributing to this project,this would be a great place to start!

  • OpenSUSE - Issue #199
  • Scientific Linux - Issue #251
  • LinuxMint Nadia - Issue #269
  • TANglu Bartholomea - Issue #81
  • Korora - Issue #130
  • FreePBX - Issue #257

Authors and Contributors

Chris Lea GitHub/chrislea Twitter/@chrislea
Rod Vagg GitHub/rvagg Twitter/@rvagg
William Blankenship GitHub/retrohacker Twitter/@retrohack3r
Harry Truong GitHub/harrytruong
Matteo Brunati GitHub/mattbrun
Brian White GitHub/mscdex
Matt Lewandowsky GitHub/lewellyn
Jan-Hendrik Peters GitHub/hennr
Andris Reinman GitHub/andris9
Carvilsi GitHub/carvilsi
Krasimir Trenchev GitHub/Ava7
Phil Helm GitHub/phelma
0xmohit GitHub/0xmohit
jdarling GitHub/jdarling
Prayag Verma GitHub/pra85
Misha Brukman GitHub/mbrukman
Simon Lydell GitHub/lydell
Sebastian Blei GitHub/iamsebastian

Contributions are welcomed from anyone wanting to improve this project!

License

This material is copyright (c) 2016 NodeSource and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

Supported with love by Chris Lea,Rod Vagg and the NodeSource team

This project is not affiliated with Debian,Ubuntu,Red Hat,CentOS or Fedora.
Ubuntu is a registered Trademark of Canonical Ltd.
Debian is a registered Trademark owned by Software in the Public Interest,Inc.
Red Hat,CentOS and Fedora are Trademarks of Red Hat,Inc.
CloudLinux is a Trademark of Cloud Linux,Inc

ubuntu 16.04 安装nodejs的更多相关文章

  1. macos – 运行brew命令充满了’同意Xcode / iOS许可证需要管理员权限,请通过sudo以root身份重新运行.’

    所以我跑了:如果滚动到底部,可以输入“同意”,然后就可以了.

  2. xcode7 – 谁在创建文件“/private/var/tmp/Untitled-*.uicatalog”?

    我正在调查为什么TeamCity构建代理程序用完了磁盘,并且在/private/var/tmp中找到了超过11,000个文件,它们都以Untitled-.uicatalog行命名.每个文件至少0.6MB.总磁盘占用空间约为4GB.这些文件可以追溯到几个月,所以他们能够重新启动.谁在创造他们?Xcode在编译至少有一个图像的xcassets目录时创建这些目录.我可以删除它们吗?

  3. ios – -bash:git:命令在lion osx的Xcode 4中找不到

    通过Xcode4.3–>file–>源控制–>存储库–>克隆存储库,我从codesion.com克隆了一个存储库.但是当我去gitinit或gitadd时,找不到错误-bash:git:command.现在,Xcode4.3附带了git,所以我该怎么做才能让它工作?

  4. [翻译]Swift编程语言——高级操作符

    高级操作符在前面的基本操作符之外,为了做更复杂的值操作,Swift还提供了若干高级操作符。不同于C中的算术操作符,Swfit中的算术操作符不会默认溢出。Swift使得为这些自定义的类型量身打造标准操作符的实现变得很轻松。预定义操作符没有任何限制,Swift提供了定制中缀、前缀、后缀和指派操作符的自由。Swfit提供所有的C支持的按位操作符,下文有具体描述。CSS颜色值#CC6699依据Swift的十六进制表示法被写作0xCC6699。)有符号整型用它们的第一个bit来表示正负。

  5. Project Perfect让Swift在服务器端跑起来-Hi Linux(二)

    开篇写了一个简单的入门,今天想说说怎么让Perfect项目在Linux上运行。Swift开源后,苹果让Swift不仅在OSX/iOS上跑,更让Swift在Linux/Windows上跑。作为服务端的Perfect框架+RemObjectSilver,让Swift成为了一个全栈语言。Perfect由于是服务端的,让Perfect在Linux上跑是必然的事情。从第一篇文章中我们可以了解到Perfect由PerfectLib和PerfectServer组成。

  6. swift – 无法绑定到0.0.0.0:8080,它可能正在使用或需要sudo

    有时我试图从Xcode运行Vapor应用程序时会收到此错误.重新打开Xcode没有帮助,只能重新启动系统.这是框架的错误吗?我该怎么办才能防止这种情况呢?如果使用sudo不能修复此消息,则表示已经绑定到此端口.它可能是一个没有正确关闭的蒸气的例子.要解决这个问题,你需要杀死前一个实例.最简单的方法是:8080是您尝试使用的端口.这样输出如下:然后使用其PID来终止绑定到该端口的进程.

  7. 如何增加Android Kitkat ADB屏幕记录的时间限制

    我正在使用ADB的屏幕录制功能来录制我的应用程序的视频.这是非常方便和有用的.只有我发现的问题是3分钟的最大时间限制.有什么办法或解决办法或方式来增加这个时间限制?解决方法在windows上我的诀窍是创建一个screenrecord.bat文件并运行它.9分钟然后,您可以将文件与任何视频编辑软件合并.我知道这是一个跛脚的解决方案,但adb屏幕录像是不允许更长的视频长度的责任…

  8. 如何在我的Android中运行BASH脚本?

    我的BASH脚本在Fedora/CentOS中工作.但是我正在测试一个Androideeepad变压器.我有终端访问,我写了一个小测试脚本.但它不工作,我该如何解决?我究竟做错了什么?我看到,虽然它被指定#!/bin/bash错误由sh发布–可能会做错了.UPD

  9. Android – Bash无法找到adb,即使它绝对在那里

    我已经尝试将platform-tools文件夹添加到我的路径以及sudo和suing,但是无论它是什么样的文件都找不到.有人知道可能发生什么事吗?解决方法您正在运行64位系统,而您没有安装32位兼容性库.这个错误实际上来自于它找不到32位ld.so的事实.如果你使用ubuntu/debian,我想你只需要sudoapt-getinstallia32-libs,它应该可以工作.

  10. nodejs编写bash脚本的终极方案分享

    你懂JavaScript吗?你需要写一个Shell脚本吗?那么你应该试一下Node.js,它很容易安装,而且很适合通过写Shell脚本来学习它,下面这篇文章主要给大家介绍了关于nodejs编写bash脚本的终极方案,需要的朋友可以参考下

随机推荐

  1. crontab发送一个月份的电子邮件

    ubuntu14.04邮件服务器:Postfixroot收到来自crontab的十几封电子邮件.这些邮件包含PHP警告.>我已经解决了这些警告的原因.>我已修复每个cronjobs不发送电子邮件(输出发送到>/dev/null2>&1)>我删除了之前的所有电子邮件/var/mail/root/var/spool/mail/root但我仍然每小时收到十几封电子邮件.这些电子邮件来自cronjobs,

  2. 模拟两个ubuntu服务器计算机之间的慢速连接

    我想模拟以下场景:假设我有4台ubuntu服务器机器A,B,C和D.我想在机器A和机器C之间减少20%的网络带宽,在A和B之间减少10%.使用网络模拟/限制工具来做到这一点?

  3. ubuntu-12.04 – 如何在ubuntu 12.04中卸载从源安装的redis?

    我从源代码在Ubuntu12.04上安装了redis-server.但在某些时候它无法完全安装,最后一次makeinstallcmd失败.然后我刚刚通过apt包安装.现在我很困惑哪个安装正在运行哪个conf文件?实际上我想卸载/删除通过源安装的所有内容,只是想安装一个包.转到源代码树并尝试以下命令:如果这不起作用,您可以列出软件自行安装所需的步骤:

  4. ubuntu – “apt-get source”无法找到包但“apt-get install”和“apt-get cache”可以找到它

    我正在尝试下载软件包的源代码,但是当我运行时它无法找到.但是当我运行apt-cache搜索squid3时,它会找到它.它也适用于apt-getinstallsquid3.我使用的是Ubuntu11.04服务器,这是我的/etc/apt/sources.list我已经多次更新了.我尝试了很多不同的debs,并没有发现任何其他地方的错误.这里的问题是你的二进制包(deb)与你的源包(deb-src)不

  5. ubuntu – 有没有办法检测nginx何时完成正常关闭?

    &&touchrestarted),因为即使Nginx没有完成其关闭,touch命令也会立即执行.有没有好办法呢?这样的事情怎么样?因此,pgrep将查找任何Nginx进程,而while循环将让它坐在那里直到它们全部消失.你可以改变一些有用的东西,比如睡1;/etc/init.d/Nginx停止,以便它会休眠一秒钟,然后尝试使用init.d脚本停止Nginx.你也可以在某处放置一个计数器,这样你就可以在需要太长时间时发出轰击信号.

  6. ubuntu – 如何将所有外发电子邮件从postfix重定向到单个地址进行测试

    我正在为基于Web的应用程序设置测试服务器,该应用程序发送一些电子邮件通知.有时候测试是使用真实的客户数据进行的,因此我需要保证服务器在我们测试时无法向真实客户发送电子邮件.我想要的是配置postfix,以便它接收任何外发电子邮件并将其重定向到一个电子邮件地址,而不是传递到真正的目的地.我正在运行ubuntu服务器9.10.先感谢您设置本地用户以接收所有被困邮件:你需要在main.cf中添加:然后

  7. ubuntu – vagrant无法连接到虚拟框

    当我使用基本的Vagrantfile,只配置了两条线:我看到我的虚拟框打开,但是我的流氓日志多次显示此行直到超时:然后,超时后的一段时间,虚拟框框终于要求我登录,但是太久了!所以我用流氓/流氓记录.然后在我的物理机器上,如果我“流氓ssh”.没有事情发生,直到:怎么了?

  8. ubuntu – Nginx – 转发HTTP AUTH – 用户?

    我和Nginx和Jenkins有些麻烦.我尝试使用Nginx作为Jenkins实例的反向代理,使用HTTP基本身份验证.它到目前为止工作,但我不知道如何传递带有AUTH用户名的标头?}尝试将此指令添加到您的位置块

  9. Debian / Ubuntu – 删除后如何恢复/ var / cache / apt结构?

    我在ubuntu服务器上的空间不足,所以我做了这个命令以节省空间但是现在在尝试使用apt时,我会收到以下错误:等等显然我删除了一些目录结构.有没有办法做apt-getrebuild-var-tree或类似的?

  10. 检查ubuntu上安装的rubygems版本?

    如何查看我的ubuntu盒子上安装的rubygems版本?只是一个想法,列出已安装的软件包和grep为ruby或宝石或其他:)dpkg–get-selections

返回
顶部