Reputation: 8990
My app is a node.js app which I can run through command line using: npm test
inside the working directory. In WebStorm, I created a new configuration that looks like this:
Node interpreter: /usr/local/bin/npm
Node parameters: test
Working directory ~/dev/project
When I hit the run button, I get the correct output:
/usr/loca/bin/npm test
> [email protected] test ~/dev/project
something else
Process finished with exit code 0
But since I have breakpoints set, it should have stopped on a breakpoint instead of getting to the Process finished part. I set my code to be pretty simple just so I can test breakpoints, so it looks like this:
"use strict";
let foo = false; (breakpoint)
let bar = true;
if (foo === bar) { (breakpoint)
console.log('something');
} else {
console.log('something else'); (breakpoint)
}
process.exit(1);
I also tried to make this work through command line. In my site settings, I set my Built-in server to port 12345. Can accept external connections, and allow unsigned requests.
when I run it through command line, I use:
npm --debug-brk=12345 test
I get the same result: it runs all the way to the exit point without stopping on the breakpoints.
Any ideas what I need to do to get this to work?
Upvotes: 1
Views: 3322
Reputation: 93888
/usr/local/bin/npm
is definitely not a Node interpreter, it's NPM package manager that is a Node.js application itself (i.e. it's run with Node.js interpreter). And test
is a name of npm script, not a Node.js parameter.
If you like to debug your .js file that is run via npm test
, you need to modify your npm script to include the debug options and then use NPM run configuration for debugging. Or, just create a Node.js configuration, set a valid path to Node.js execuitable there (/usr/bin/node
or whatever it looks like on your system), then specify your .js
file as JavaScript file:. See https://blog.jetbrains.com/webstorm/2017/09/debugging-node-js-apps-in-webstorm for more info
Upvotes: 2