Creating Your First Node.js Application

Follow these instructions to create your fist nodejs application is less than 5 mins.

I assumed you already have nodejs and npm installed on your machine, if not please follow “How to install nodejs” tutorial and come back here after installation is completed.

Open command promt in admin mode and go to the folder where you want to create your first nodejs project. Install express and express-generator using following commands.

npm install express –save  
npm install express-generator –save`  

There are multiple templating option that you can choose such as handlebars, pug, hogan but I choose ejs as its very user friendly and it does not have steep learning curve. Create your first nodejs app by using following command

express --view=ejs myapp  

cd into new folder and install node packages by using following commands

cd . && npm install  

And you are all set. Start your nodejs application by using following command. This will start your application in debug mode.

SET DEBUG=myapp:* & npm start  

If you don’t want to start application in debug mode you can just simple start Node.js app using following command

npm start  

This will get you started with nodejs under 5 minutes. This will create your bare minimum nodejs application. now you can go ahead and do any further front end development that you need.

Our nodejs application is just like steel frame, it just send you one simple webpage, nothing else, we can enhance it further to create data feed api and other complex features. We will look at step by step guide of these at later stages.