Install the latest stable version of node and npm on ubuntu

background


The latest LTS version is installed through the ubuntuofficial aptinstallation tool , and nodeI am a bit of an obsessive-compulsive person . Command line command:nodeubuntunodenpm

sudo apt install nodejs-legacy
sudo apt install npm

How to install the latest version


1. Installationnpm

sudo apt install npm

2. Upgrade npmto the latest version

sudo npm install npm@latest -g

At this point , it npm -vcan be found that npmthe version number is the latest version 3.10.3;
3. Install nodejsthe module for installationn

sudo npm install -g n

4. Then ninstall the specified version through the nodejsmodule. nFor more introduction to the module, please refer to the official documentation

//安装官方最新版本
sudo n latest
//安装官方稳定版本
sudo n stable
//安装官方最新LTS版本
sudo n lts

We install the stable version nodejs, and then we node -vcan find that the nodeinstallation is successful and the version number is the v6.2.0stable version

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112267&siteId=291194637