The Simplest Explanation & Question
Assume that we are Webpack developers and debugging the Webpack (well, nothing will change for this question if substitute Webpack with Gulp or Vite). We have done npm install webpack
to some project. When run the webpack build
via console, maybe we will use some options, for example, npx webpack build --config ./webpack.config.js --stats verbose
. There are some debugger
statements in the source code of Webpack version which we have installed.
How to make Webpack stop when debug statement will reached?
My case
My utility is similar to Webpack. Well, it uses the Webpack, and also Gulp as dependencies. As pure Webpack and Gulp, my utility is intended to be executed in other projects so it is completely useless to run it without external project.
As Webpack and Gulp, once installed to another project, it is being called by CLI:
myutil build --mode production
myutil
command has been declared in the package.json of my utility:
{
// ...
"bin": {
"myutil": "Executable"
},
}
How it generally being done?
Well, it has been clearly answered in another topics.
To debug a Node.js application, one can use the debugging built-in method:
(1) Insert debugger; statement where you want to insert a break point (2) Run the file with command $ node inspect (3) Use a key for example, c to continue to next break point
Alternatively, node --inspect-brk Test.js
.
Why it is not suited with my case?
Because the application is being launched via CLI like myutil build --mode production
.
As far as I can assume, the Node.js, basing on "bin": { "myutil": "Executable" }
declaration in package.json
of dependency executing the Executable
, the JS file wiht #!/usr/bin/env node
shebang line.
As I previously said, there is completely useless to execute node inspect Executable
because my utility is not intended to be executed inside own package and will fail with error.
Additionally, my utility has some required parameter and will throw error is detect some unexpected parameters.
What I am debugging?
The RangeError: Maximum call stack size exceeded
error. Additionally, if to try console.log
, it will instantly overflow the terminal and some initial outputs will be truncated. I need the stop by debugger
very much.
The Simplest Explanation & Question
Assume that we are Webpack developers and debugging the Webpack (well, nothing will change for this question if substitute Webpack with Gulp or Vite). We have done npm install webpack
to some project. When run the webpack build
via console, maybe we will use some options, for example, npx webpack build --config ./webpack.config.js --stats verbose
. There are some debugger
statements in the source code of Webpack version which we have installed.
How to make Webpack stop when debug statement will reached?
My case
My utility is similar to Webpack. Well, it uses the Webpack, and also Gulp as dependencies. As pure Webpack and Gulp, my utility is intended to be executed in other projects so it is completely useless to run it without external project.
As Webpack and Gulp, once installed to another project, it is being called by CLI:
myutil build --mode production
myutil
command has been declared in the package.json of my utility:
{
// ...
"bin": {
"myutil": "Executable"
},
}
How it generally being done?
Well, it has been clearly answered in another topics.
To debug a Node.js application, one can use the debugging built-in method:
(1) Insert debugger; statement where you want to insert a break point (2) Run the file with command $ node inspect (3) Use a key for example, c to continue to next break point
Alternatively, node --inspect-brk Test.js
.
Why it is not suited with my case?
Because the application is being launched via CLI like myutil build --mode production
.
As far as I can assume, the Node.js, basing on "bin": { "myutil": "Executable" }
declaration in package.json
of dependency executing the Executable
, the JS file wiht #!/usr/bin/env node
shebang line.
As I previously said, there is completely useless to execute node inspect Executable
because my utility is not intended to be executed inside own package and will fail with error.
Additionally, my utility has some required parameter and will throw error is detect some unexpected parameters.
What I am debugging?
The RangeError: Maximum call stack size exceeded
error. Additionally, if to try console.log
, it will instantly overflow the terminal and some initial outputs will be truncated. I need the stop by debugger
very much.
1 Answer
Reset to default 0If Executable
imports the entry point which executing the application (for example index.js
), than the debugging is possible by:
node --inspect-brk node_modules/myutil/index.js [options]
Any options of myutil
could be passed at [opiton]
placeholder.