debug Webstorm package.json that calls `npx nps <script>` with multiple projects running
We have this `package.json`:
"scripts": {
"start": "npx nps local",
...
}
And the package-scripts.json contains:
local: {
description: 'Creates a local environment for development',
default: series(
'cp -n .env.local.dist .env.local || true',
'npx nps clean',
'npx nps local.start',
),
start: concurrent({
bootstrap: series(mkdirp('.bootstrap'), 'npx nps local.bootstrap'),
macroui: 'npx nps local.macroui',
microui: series(mkdirp('.microui'), 'npx nps local.microui'),
express: 'npx nps local.express',
}),
bootstrap: `cross-env BABEL_CONTEXT=client npx webpack -w --mode production --host 0.0.0.0 --config ./webpack.bootstrap.dist.js`,
macroui: `cross-env NODE_ENV=development ENV_ID=local npx webpack-dev-server --host 0.0.0.0 --config ./webpack.macro.dev.js`,
microui: `cross-env NODE_ENV=development ENV_ID=local BABEL_CONTEXT=client npx webpack -w --mode development --host 0.0.0.0 --config ./webpack.micro.dev.js`,
express: `cross-env NODE_ENV=development ENV_ID=local BABEL_CONTEXT=server nodemon --watch srv --exec babel-node srv/boot.js`,
},
I can create a configuration with `npx nps local` and hit `run` to have the multiple processes start correctly.
But hitting `debug` fails to start them correctly and of course debugging isn't working.
Does anyone have any suggestions for how to get this to start under the debugger?
Please sign in to leave a comment.
>hitting `debug` fails to start them correctly and of course debugging isn't working.
please could you elaborate on this? what do you mean saying that they don't start correctly?
Here is what the run console looks like when it is started with 'run':
Here it what the debug console looks like:
The `run` builds:
The `debug` doesn't seem to build anything. And the logger that is outputing '[macroui]' doesn't seem to be running correctly.
Weird... My only guess is that your scripts use the
NODE_OPTIONS
environment variable somehow and, as the debugger uses NODE_OPTIONS environment variable for automatic connection to child processes, it gets overwritten causing the issue. Could you check if disablingjs.debugger.use.node.options
key in Registry (in Help | Find action..., typeregistry
... to locate it) makes any difference?Yes Elena, great work, thanks! That does seem to fix the issue.
However NODE_OPTIONS is not set anywhere - not in the WebStorm RUN configuration, not in any scripts and nor in the environment. I added
debug: 'echo NODE_OPTIONS: $NODE_OPTIONS',
to the package-scripts.js and it has no value.
I'm expecting that debugging will not work with this turned off. Ideas?
----
Confirmed - break points don't work
I see the debugger starts with
Does `NODE_OPTIONS` get set to `-inspect-brk=65520`?
Jetbrains should get themself added to the list of debug clients in https://nodejs.org/en/docs/guides/debugging-getting-started/
>Confirmed - break points don't work
this is https://youtrack.jetbrains.com/issue/WEB-55805, please follow it for updates
>Does `NODE_OPTIONS` get set to `-inspect-brk=65520`?
yes, more or less - it's supposed to set it for all spawned child processes
But you only need debugging yoiur express app, don't you? seems the only thing I can suggest for now is re-defining your script, separating the stuff that has to be debugged from webpack, etc. processes
Hi Elena,
> only need for express app
Possibly. I will have to look at it more closely. I might take a while to get this done due to other priorities.
Thanks for your help so far.
Cheers,
Brooke