I have a NodeJS project with a package.json
file that contains following lines:
"scripts": {
[...]
"start:dev": "cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js",
[...]
}
I can start the program in the mand line using npm run start:dev
.
Now I want to debug some of the code. For this purpose I created a NodeJS Run configuration in Idea with the following parameters (pasted cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js
into Node Parameters
).
When I run it, I get the following error:
/usr/bin/node cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js
Debugger listening on ws://127.0.0.1:43392/5a2c1e8e-a508-4578-8eb0-2bc4f4a63b30
For help, see:
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module '/home/JIT/d.pisarenko/Development/Repositories/git/myproject/cross-env'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Process finished with exit code 1
What do I need to change in order to be able to start the application in Idea and debug it?
I have a NodeJS project with a package.json
file that contains following lines:
"scripts": {
[...]
"start:dev": "cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js",
[...]
}
I can start the program in the mand line using npm run start:dev
.
Now I want to debug some of the code. For this purpose I created a NodeJS Run configuration in Idea with the following parameters (pasted cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js
into Node Parameters
).
When I run it, I get the following error:
/usr/bin/node cross-env NODE_ENV=local supervisor --watch src -- -r '@babel/register' src/server/index.js
Debugger listening on ws://127.0.0.1:43392/5a2c1e8e-a508-4578-8eb0-2bc4f4a63b30
For help, see: https://nodejs/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module '/home/JIT/d.pisarenko/Development/Repositories/git/myproject/cross-env'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Process finished with exit code 1
What do I need to change in order to be able to start the application in Idea and debug it?
Share Improve this question asked Apr 22, 2020 at 15:05 Glory to RussiaGlory to Russia 18.8k60 gold badges200 silver badges344 bronze badges 5-
Do you have
cross-env
installed globally for the Node version IntelliJ is using? – jonrsharpe Commented Apr 22, 2020 at 15:08 - @jonrsharpe No (at least I don't remember installing it globally). – Glory to Russia Commented Apr 22, 2020 at 15:09
-
Then it shouldn't be particularly surprising that doesn't work! Why not use the NPM task runner to use the existing
start:dev
? – jonrsharpe Commented Apr 22, 2020 at 15:10 - @jonrsharpe How exactly can I do it so that the breakpoints work in Idea? – Glory to Russia Commented Apr 22, 2020 at 15:10
- I didn't have to do anything special, just add an npm configuration, select the script I wanted and click debug. – jonrsharpe Commented Apr 22, 2020 at 15:17
1 Answer
Reset to default 9Found the answer. You need to click the green arrow next to the script definition (next to the line numbers 8 and 9):
There you can select whether to run or debug the script.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744187906a4562294.html
评论列表(0条)