Install Node.js and create your first Express application

In this tutorial, we will explain how to install Node.js and create your first Express JS application on an Ubuntu 16.04 VPS. Express is an open source, fast and flexible web development framework for node.js and provides a robust set of features to develop web and mobile applications. Express is to Node.js what Ruby on Rails is to Ruby. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.

Install Node.js

The following instructions assume that you don’t have Node.js installed on your machine.

We will install the Node.js version 4 LTS Argon from the nodesource (formerly Chris Lea’s Launchpad PPA) repository.

The command bellow will add the nodesource signing key to your apt keyring, add the deb.nodesource.com repository to your apt sources and run apt-get update to update the package sources.

Install Express

The easiest way to create a new Express projects is a tool called an Express application generator. The application generator tool (express-generator) will help you to quickly create an Express application skeleton.

You can now create a new express application using the express generator tool:

[user]$ express myNewApp

The command above will create a new barebone express application in the myNewApp directory.

Switch to myNewApp directory and install all the default dependencies using the npm tool with the following commands:

[user]$ cd myNewApp
[user]$ npm install

Once all the dependencies are installed start the application with the following command:

[user]$ DEBUG=myNewApp:* npm start

You should now have an express application running at: http://localhost:3000 . Open the link in your web browser and you should see something like below:

Express
Welcome to Express

That’s it. You have successfully created your first Express JS application on your Ubuntu 16.04 machine. For more information about Express, please refer to the official Express documentation.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.