server node + express structures, modified automatically reboot the server

1. express a building project, the following steps (step mounted omitted node)

 a. mounting global express-generator (express generator)

above sea level and express-generator g

 b.express a project

express test

 c. to change into the root directory of the project

cd test

 d. Install dependent

npm install

2. Global installation nodemon

above sea level and -g nodemon

3. Create nodemon.json file in the root directory of the project, as follows

{
  "restartable": "rs",
  "ignore": [
    ".git",
    ".svn",
    "node_modules/**/node_modules"
  ],
  "verbose": true,
  "execMap": {
    "js": "node --harmony"
  },
  "watch": [
    
  ],
  "env": {
    "NODE_ENV": "development"
  },
  "ext": "js json njk css js "
}

4.package.json of scripts add the following content and save the file

"dev": "nodemon ./bin/www"

 Adding an effect roughly as follows:

{
  "name": "test",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "dev": "nodemon ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.9",
    "express": "~4.16.0",
    "http-errors": "~1.6.2",
    "jade": "~1.11.0",
    "morgan": "~1.9.0"
  }
}

5. Start project

asl run auto 

 or

npm run dev

 

Guess you like

Origin www.cnblogs.com/blogNGNL/p/10971349.html