Showing posts with label express.js. Show all posts
Showing posts with label express.js. Show all posts

Monday 7 September 2015

Express.js Running Application

There is a tutorial for installing new running Express js application!

Installing Node.js:
1- Go to this link "https://nodejs.org/" and install node.js.
2- Go to Shell and intall express generator using "npm install express-generator -g"

For New Express Application:
1- Make a directory i.e., D:\nodePractice.
2- Go to this directory and from shell "npm install express". It will create a folder in this directory called 

"node-modules".
3- Go to "node-modules" and from shell make "package.json" file using "npm init"!
While creating this file it is gonna ask for some things like appname, description, test-command etc. Enter the desired text there!
3- Go to "node-modules" directory and from shell install express application using "express" command.
4- Add This code to your app.js file created in "node-modules" directory:

var server = app.listen(3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});

5- Run app.js file!
6- intall missing modules using 'npm intall <module-name>' e.g, "npm install serve-favicon"
7- Run app.js again! Bang there you are...