Search code examples
node.jsexpressnpmwebstormnodemon

nodemon not able to start nodejs app with express v4


There must have some simple solution with this problem. I have created a new project using Webstorm for Express js + Node js. Then i installed nodemon using npm install -g nodemon and it was fine. But when i am trying to start my app using nodemon app.js it is showing only

sany2k8@sany2k8-Aspire-4752:/var/projects/ENStack$ nodemon app.js

[nodemon] 1.9.2

[nodemon] to restart at any time, enter rs [nodemon] watching: .

[nodemon] starting node app.js

[nodemon] clean exit - waiting for changes before restart

package.json

{
  "name": "ENStack",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

Edit: When i tried with npm start then it is showing bunch of errors

sany2k8@sany2k8-Aspire-4752:/var/projects/ENStack$ npm start

ENStack@0.0.0 start /var/projects/ENStack node ./bin/www

Port 3000 is already in use


Solution

  • we need to add start with nodemon ./bin/www in the json file and run your project using: nodemon app

    {
      "name": "ENStack",
      "version": "0.0.0",
      "private": true,
      "scripts": {
        "start": "nodemon ./bin/www"
      },
      "dependencies": {
        "body-parser": "~1.13.2",
        "cookie-parser": "~1.3.5",
        "debug": "~2.2.0",
        "express": "~4.13.1",
        "jade": "~1.11.0",
        "morgan": "~1.6.1",
        "serve-favicon": "~2.3.0"
      }
    }