Installing Node.js and Express on Ubuntu

Powered by the Chrome V8 Engine, Node.js is a popular language used to build fast scalable applications. It has already powered numerous projects including Express. This tutorial will show you how to install Node.js and Express.js on Ubuntu 14.04.

Step 1: Download Node.js

You would want to download the latest stable version of Node.js. On your server, run the following command to download and extract Node.js:

cd /tmp
wget http://nodejs.org/dist/v0.10.32/node-v0.10.32-linux-x64.tar.gz
tar xvf node-v0.10.32-linux-x64.tar.gz

Step 2: Install Node.js

Run the following commands. These will install node js by copying everything in node-v0.10.32-linux-x64 into /usr/local:

cd node-v0.10.32-linux-x64/
cp * /usr/local/ -r
cd ~

Now run node -v. If you see v0.10.32, then you then have successfully installed Node.js.

Step 3: Install Express.js

Now for the Express tutorial. To get started, you will need to run the following command to install Express generator. Express generator helps to easily create your project.

npm install -g express-generator

Once that is done, test to make sure Express generator is installed by running express -h. Upon success, it will show you a list of available options.

Step 4: Create a Project

Even though there are several options that you can choose from, we will stick with the default when creating our project. To create a project, run the following commands on your server:

express expressproject
cd expressproject
npm install

This first creates a new folder called expressproject. Inside it, you will see 2 files called app.js and package.json, and 5 directories called binnode_modulespublicroutes, and views. This will also install Express for your project. You can now run npm start to start your Express server. If everything is setup correctly, you will see the following:

> expressproject@0.0.0 start /root/expressproject
> node ./bin/www

In your web browser, navigate to the IP address of your VPS at port 3000. The URL is as follows (replace 0.0.0.0 accordingly):

http://0.0.0.0:3000

Upon success, you will see Welcome to Express on the page in your browser.

You have successfully setup Node.js with Express!

  • Installing Node.js and Express on Ubuntu
  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

Setting up a Name Server for IPv6 rDNS in CentOS

Managing your own IPv6 rDNS is a fairly simple task. After setting up the name server, please...

Reset the Root Password in CentOS

If you have forgotten the root password it is possible to set a new one by interrupting the boot...

Installing Ubuntu Server on Drives Larger Than 2 TB

The following tutorial requires a motherboard that is EFI compatible (most boards since 2012 are...

Enabling root user in Ubuntu

Instructions on how to enable root user in a newly installed Ubuntu server. The root user in...

How to Install and Configure vsftpd on CentOS 7

FTP (File Transfer Protocol) is one of the most popular methods to upload files to a server....