Table of Contents
Was this article helpful?

2  out of  2 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

Installing Node.js and Express on Ubuntu

Last Updated: Tue, Sep 30, 2014
Linux Guides Node.js Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

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
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 bin, node_modules, public, routes, 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 accordingly):

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

You have successfully setup Node.js with Express!

Want to contribute?

You could earn up to $600 by adding new articles