安装最新的LTS版本Node.js(NodeJS)和Node.js的包管理(NPM)在目前所有支持版本的Ubuntu,打开终端,运行以下命令:
sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
The nodejs package contains the nodejs binary as well as npm, so you don't need to install npm separately. However, in order for some npm packages to work (such as those that require building from source), you will need to install the build-essential package:
翻译:
包中包含的Nodejs NodeJS二进制以及新公共管理的,所以你不需要安装单独的NPM。然而,对于一些新包装工作,(如那些需要从源代码构建),您将需要安装build-essential包
sudo apt-get install build-essential
LTS Plan
New semver-major releases of Node.js are cut from master every six months. New even-numbered versions (e.g. v6, v8, v10, etc.) are cut in April. New odd-numbered versions (e.g. v5, v7, v9) are cut in October.
When a new odd-numbered major release is cut, the previous even-numbered major version transitions to the Long Term Support plan.
Every major version covered by the LTS plan will be actively maintained for a period of 18 months from the date it enters LTS coverage. Following those 18 months of active support, the major version will transition into "maintenance" mode for 12 additional months.
non-LTS installation
Current to March, 2017 the commands to install the latest non-LTS version of Node.js (v8 at the time this was posted) are as follows:
sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js LTS Schedule
Release LTS Status Codename LTS Start Maintenance Start Maintenance End
6.x Active Boron 2016-10-18 April 2018 April 2019
7.x No LTS
8.x Active Carbon 2017-10-31 April 2019 December 2019
9.x No LTS
10.x Pending Pending October 2018 April 2020 April 2021
淘宝 NPM 镜像
你可以使用我们定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:
$ npm install -g cnpm –registry=https://registry.npm.taobao.org
转载请注明:R&M » Ubuntu使用apt-get安装nodeJs