10

I am using npm start to start my MEAN stack application, but I would like to use the node-inspector to debug some Mongoose. I know I can start the node inspector with node-inspector, but what can I substitute node --debug app.js with to make npm start work in my case?

This is my MEAN stack directory structure:

HTML        views/
Angular.js  public/javascript/
Express.js  routes/
Node.js     app.js
Mongoose js models/, connected in app.js
Mongo db    connected in app.js

For more information, this is my related question.

Community
  • 1
  • 1
Melissa
  • 1,236
  • 5
  • 12
  • 29

3 Answers3

12

You may want to add a seperate debug script to package.json. That way you won't have to remember to revert npm start when you're finished debugging.

"scripts": {
    "start": "node ./bin/www",
    "debug": "node --debug ./bin/www"
}

Start with npm run:

$ npm run debug
joews
  • 29,767
  • 10
  • 79
  • 91
  • 7
    DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead. – HASNEN LAXMIDHAR Jan 02 '19 at 07:36
3

In package.json modify the start run command:

"scripts": {
    "start": "node --debug app.js"
}
Miguel Mota
  • 20,135
  • 5
  • 45
  • 64
0

I use it like this, I also set a variable and run the inspector in one command: npm run debug

"scripts": {
  "start": "set SOAPAPI=https://example.com/&&nodemon",
  "debug": "start node-inspector --web-port=8081&&set SOAPAPI=https://example.com/&&nodemon --debug"
}

*nodemon is an utility wrapper for node, you can use node instead

Qwerty
  • 29,062
  • 22
  • 108
  • 136