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.
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
Run the following commands. These will install node js by copying everything in
cd node-v0.10.32-linux-x64/ cp * /usr/local/ -r cd ~
node -v. If you see
v0.10.32, then you then have successfully installed Node.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.
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
package.json, and 5 directories called
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:
> firstname.lastname@example.org 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
Upon success, you will see
Welcome to Express on the page in your browser.
You have successfully setup Node.js with Express!