Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webstorm Debugging NPM Script Through IDE

Trying to debug an NPM script from within Webstorm. The application runs through the NPM scripts, but when debugging the script it always crashes. I know that there is the flag $NODE_DEBUG_OPTION, but adding that doesn't seem to work.

Script:

"dev": "npm run dev:server & npm run build:client:watch",
"dev:server": "npm run build:server:watch & nodemon --harmony lib/server",
"build:client:watch": "WEBPACK_DEV=true NODE_ENV=development STACK=local node lib/server/webpack",
"build:server:watch": "npm run transpile:watch -- -d lib/common src/common & npm run transpile:watch -- -d lib/server src/server",
"transpile": "BABEL_ENV=node babel",
"transpile:watch": "npm run transpile -- --watch",

According to Webstorm: To debug the "dev" script, make sure the $NODE_DEBUG_OPTION string is specified as the first argument for the node command you'd like to debug. For example: { "start": "node $NODE_DEBUG_OPTION server.js" }

But even when adding this in different places it will still give me an error. Any suggestions?

like image 444
Jmrapp Avatar asked Sep 18 '25 23:09

Jmrapp


1 Answers

For anyone reading this in 2020, you just need to right-click the script in the NPM panel and select "Debug ".

You can then set breakpoints in the script and debug in the Debug panel panes, Debugger, Console, etc..

To re-run the script, click the bug icon in the Debug panel.

like image 136
Dave Stewart Avatar answered Sep 21 '25 14:09

Dave Stewart