Installing Express with nodejs

Installing Express with nodejs project dependency

  1. Create project folder and open the folder using  command prompt
  2. execute the following  commands
  3. Create project using  npm init command

expressjs

4. Now install Express in the app directory and save it in the dependencies list using :-  npm install express --save (To install Express temporarily and not add it to the dependencies list, omit the --save option)

expressjs

you can see the express is added to the project dependency

5. You can install the following supporting libraries also

body-parser – This is a node.js middleware for handling JSON, Raw, Text and URL encoded form data.

cookie-parser – Parse Cookie header and populate req.cookies with an object keyed by the cookie names.

multer – This is a node.js middleware for handling multipart/form-data.

6. Create a sample code

7 Run the server using node index.js open http://127.0.0.1:8000/ in your browser 

expressjs

Done

 

There a node package nodemon, “Nodemon is a utility that will monitor for any changes in your source and automatically restart your server. Perfect for development”

Running our project with nodemon

nodemon

 

How to use express generator for creating project http://wiki.workassis.com/nodejs-express-application-generator/

  Like
Author: bm on August 1, 2016
Category: NodeJs

Your comment:

Your Name

Comment:




Last articles