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:
sudo apt-get install build-essential
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.
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