node.js

kill node if rerun and Port 3000 is already in use

pkill node

change nodejs use nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

nvm ls

for node8

nvm use 8

update nodejs and nvm

Install npm =>

sudo apt-get install npm

Install n =>

sudo npm install n -g

latest version of node =>

sudo n latest

Node.js v10.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros

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

Node.js v9.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros

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

Node.js v8.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros

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

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

connect to database

There are multiple ways on how to install Node.js on your Ubuntu 16.04 Xenial Xerus Linux server. The below steps will show you how to install Node.js using a standard Ubuntu repository, PPA repository, Node.js native setup script and by use of Node Version Manager. The easiest installation is by using standard Ubuntu repository, however it yields lower Node.js version. If you need a bleeding-edge Node.js version you better opt for an automatic installation using the Node.js native setup script.

node.js installation from Ubuntu Repository

Installation of Node.js using Ubuntu's standard repository cannot be simpler:

$ sudo apt-get install nodejs

You may also want to install Node.js package manager npm:

$ sudo apt-get install npm

Check for installed versions:

$ nodejs --version v4.2.6 $ npm --version 3.5.2

Using PPA repository

If applicable, first make add-apt-repository command available on your system:

$ sudo apt-get install python-software-properties

Next, add PPA repository:

$ sudo add-apt-repository -y -r ppa:chris-lea/node.js $

sudo curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key |sudo apt-key add -

Set a version number of Node.js you wish to install:

VERSION=node_7.x DISTRO="$(lsb_release -s -c)"

Configure, Node.js repositories with the above settigns:

$ sudo echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list $ sudo echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

At this point simple execute the below apt-get commands to install Node.js:

$ sudo apt-get update $ sudo apt-get install nodejs

Check correctness of the installation:

$ nodejs --version v7.2.1 $ npm --version 3.10.10

Node.js setup script

Using a native Node.js setup script is probably the most easiet way how to install latest Node.js version on your Ubuntu 16.04 Linux server:

$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - $ sudo apt-get install nodejs

All done. Check versions:

$ nodejs --version v7.2.1 $ npm --version 3.10.10

nvm installation

In case none of the above Node.js install fit your environment, the below manual installation using nvm might prove helpful. First, install all prerequisites:

$ sudo apt-get install build-essential libssl-dev

Install nvm using its native installation script. Correct the version number within the below URL if necessary:

# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

Source new NVM settings:

$ . ~/.profile

Find an appropriate version number. For example the below command will list all LTS Node.js releases so far:

$ nvm ls-remote | grep -i lts v4.2.0 (LTS: Argon) v4.2.1 (LTS: Argon) v4.2.2 (LTS: Argon) v4.2.3 (LTS: Argon) v4.2.4 (LTS: Argon) v4.2.5 (LTS: Argon) v4.2.6 (LTS: Argon) v4.3.0 (LTS: Argon) v4.3.1 (LTS: Argon) v4.3.2 (LTS: Argon) v4.4.0 (LTS: Argon) v4.4.1 (LTS: Argon) v4.4.2 (LTS: Argon) v4.4.3 (LTS: Argon) v4.4.4 (LTS: Argon) v4.4.5 (LTS: Argon) v4.4.6 (LTS: Argon) v4.4.7 (LTS: Argon) v4.5.0 (LTS: Argon) v4.6.0 (LTS: Argon) v4.6.1 (LTS: Argon) v4.6.2 (LTS: Argon) v4.7.0 (Latest LTS: Argon) v6.9.0 (LTS: Boron) v6.9.1 (LTS: Boron) v6.9.2 (Latest LTS: Boron)

Use nvm command to install your desired Node.js version. For example the below command will install a latest LTS Node.js release:

$ nvm install 6.9.2 ######################################################################## 100.0% Computing checksum with sha256sum Checksums matched! Now using node v6.9.2 (npm v3.10.9) Creating default alias: default -> 6.9.2 (-> v6.9.2)

Check versions:

$ node --version v6.9.2 $ npm --version 3.10.9