Wednesday, July 1, 2020

how to run a node.js application in debug mode?

it is very convenient to trouble shot a node.js application when we run it under debug mode.

here is the line that we can execute in the command line within the project folder in the CMD

set DEBUG=* & node main (for project with main.js as the start up file)

or
set DEBUG=* & node index (for project setting index.js as the entry point.

or we can add the following code to the script section in the package.json file.

"debug": "set DEBUG=* node main"


here is the sample from my node.js application.

  "scripts": {
    "start""node main.js",
    "test""echo \"Error: no test specified\" && exit 1",
    "debug""set DEBUG=* & node main"
  },

then we can start the application with the following line

npm run debug

No comments:

Post a Comment