Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging nodejs run by babel-node with WebStorm

I have npm run script in package.json:

"scripts": {
   "start": "nodemon lib/app.js --exec babel-node --presets es2015,stage-2"
}

How do you start a debugging session on WebStorm with this script?

like image 541
Tomohiro Koana Avatar asked Feb 07 '23 16:02

Tomohiro Koana


1 Answers

Right-click on package.json in the Project view and select "Show npm Scripts":

enter image description here

This will display the npm Tool Window with a list of your scripts. Right-click on a script and select Debug 'start' (for example):

enter image description here

NPM Tool Window

For the debugger to work (so that it stops at breakpoints, etc.) you need to add the string $NODE_DEBUG_OPTION to the script definition, for example:

"scripts": {
   blah: node $NODE_DEBUG_OPTION blah.js
}
like image 84
camden_kid Avatar answered Feb 28 '23 10:02

camden_kid