How to Install Node.js On Your Linux VPS or Dedicated Server

If you have VPS web hosting, then you have access to Node.JS (Node), a powerful tool to create and run network applications. Node is the N in the MEAN Stack, one of the most popular web stacks used with VPS hosting.
Along with Node, you’ll get the node package manager (npm), giving you access to the most extensive set of open source libraries in the world.

Special Note: If node.js is a must for you, make sure to find a web host that fully supports it. While most hosting services only support Node.js on their VPS plans, some, like FastComet also offer it in shared plans. You can find this information and more on HostAdvice’s Node.js hosting reviews page.

Section 1 – Install the Long-term Support (LTS) version of Node

While apt-get is a useful package manager, it does not reliably install the latest stable version of Node for Ubuntu. Instead, install from the NodeSource Debian and Ubuntu binary distributions repository (formally known as Launchpad PPA). The LTM of Node is 8.x for Linux and will be until December of 2019.

Step 1 – Update Your VPS

If you’re using an Ubuntu virtual server, update the package index.

$ sudo apt-get update

If you’re using a CentOS virtual server, update your virtual server.

$ sudo yum check-update
$ sudo yum upgrade
$ sudo yum clean all

Step 2 – Install Node in Your Home Directory

Logged in as the user with which you’re going to use Node, go to your home directory if you’re not already there.

$ cd ~

Verify that you are currently in your home directory.

$ pwd

The print working directory (pwd) command should return a path ending with your username, indicating your current working directory is your home directory.

/home/username

Step 3 – Install Node

Pipe together these three commands to download and install the latest stable Node version for Ubuntu 16.04, which is 8.x until December of 2019.

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

Step 4 – Install Build Essential

As the name suggests, Build Essential includes some important packages. It’s likely that you installed it with the process above but to make sure, install Build Essential.

$ sudo apt-get install build-essential

Step 5 – Check the Version Number of Node

You’ll want to check the version number of Node and the nvm to make sure you’ve installed Node.js version 8.x and npm version 5.x.

$ nodejs -v

The version number should return 8.x. The key is that the version starts with an 8 as 8.x is the Long-term Support (LTS) version of Node and will be the LTS until December of 2019.

V8.11.1

Then, check the version number of the node package manager (npm).

$ npm -v

It should return 5.x.

5.6.0

Conclusion

You’ve now successfully installed the latest stable release of Node.js and the npm for Ubuntu 16.04. You have now added a powerful tool to your VPS web hosting.

A good next step would be to <Create a Simple Web Server Using Node.js On Your Linux Virtual Server> as a way to understand the basics of how Node.JS works on the backend.

Check out the top 3 Node.js hosting services:

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
Kamatera
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Hostens
$2.00 /mo
Starting price
Visit Hostens
Rating based on expert review
  • User Friendly
    4.5
  • Support
    3.8
  • Features
    4.3
  • Reliability
    4.5
  • Pricing
    4.8

How to Create a Simple Web Server Using Node.js and Express

This tutorial shows you how to create a simple web server using Node.JS and Expr
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Install the MEAN Stack on Your Ubuntu 17.10 Server

The article is step-to-step instruction that shows how to install the MEAN (Mong
3 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Install the MEAN Stack on Your CentOS 7 VPS or Dedicated Server

This how-to article will show you how to install the MEAN (MongoDB, Express, Ang
2 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Set Up SSH on a CentOS 7 VPS from a Windows Client

Download puttygen into the Windows machine as shown in figure 1. Then sta
4 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.