{"id":19748,"date":"2016-08-01T07:57:09","date_gmt":"2016-08-01T12:57:09","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=19748"},"modified":"2022-06-03T03:42:45","modified_gmt":"2022-06-03T08:42:45","slug":"install-node-js-and-create-your-first-express-application","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-node-js-and-create-your-first-express-application\/","title":{"rendered":"Install Node.js and create your first Express application"},"content":{"rendered":"
<\/p>\n
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<\/a> 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<\/a>. The following instructions assume that you don’t have Node.js installed on your machine.<\/p>\n We will install the Node.js version 4 LTS Argon from the nodesource (formerly Chris Lea’s Launchpad PPA) repository.<\/p>\n 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 When the command above completes, install the Node.js package with:<\/p>\n To check the Node.js version installed on your machine run:<\/p>\n The output should be similar to the following:<\/p>\n 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.<\/p>\n Install the express-generator globally using the following command:<\/p>\n You can check the command options with the –help option:<\/p>\n You can now create a new express application using the express generator tool:<\/p>\n The command above will create a new barebone express application in the myNewApp directory.<\/p>\n Switch to myNewApp directory and install all the default dependencies using the npm tool\u00a0with the following commands<\/span>:<\/p>\n Once all the dependencies are installed start the application with the following command:<\/p>\n You should now have an express application running at: That\u2019s 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.<\/p>\n Of course you don\u2019t have to Install Node.js and create your first Express application, if you use one of our Blazing-Fast SSD\u00a0 VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install this for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/strong>.<\/span><\/span> If you liked this post on how to Install Node.js and create your first Express application, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this tutorial, we will explain how to install Node.js and create your first Express JS application on an Ubuntu … <\/p>\n
\n<\/p>\n1. Install Node.js<\/h2>\n
apt-get update<\/code> to update the package sources.<\/p>\n
[user]$ sudo wget -qO- https:\/\/deb.nodesource.com\/setup_4.x | sudo bash -<\/pre>\n
[user]$ sudo apt-get install -y nodejs<\/pre>\n
[user]$ node --version<\/pre>\n
v4.4.7<\/pre>\n
2. Install Express<\/h2>\n
[user]$ sudo npm install express-generator -g<\/pre>\n
[user]$ express -h\r\n\r\n Usage: express [options] [dir]\r\n\r\n Options:\r\n\r\n -h, --help output usage information\r\n -V, --version output the version number\r\n -e, --ejs add ejs engine support (defaults to jade)\r\n --hbs add handlebars engine support\r\n -H, --hogan add hogan.js engine support\r\n -c, --css add stylesheet support (less|stylus|compass|sass) (defaults to plain css)\r\n --git add .gitignore\r\n -f, --force force on non-empty directory\r\n\r\n<\/pre>\n
[user]$ express myNewApp<\/pre>\n
[user]$ cd myNewApp\r\n[user]$ npm install<\/pre>\n
[user]$ DEBUG=myNewApp:* npm start<\/pre>\n
http:\/\/localhost:3000<\/code> . Open the link in your web browser and you should see something like below:<\/p>\n
Express\r\n\r\nWelcome to Express<\/pre>\n
\n