debug a nodejs process without inspect flags.
Note: works only on node>=8
Debugging currently requires providing the main
node process flags like
It works great, but sometimes we don't have full control over the process flags because we execute the process through a wrapper, generally
gulp and so many others.
Node 8 comes with the
inspector module, which allows users to programmatically open an
inspector in a blocking way is a bit cumbersome though, that's why this lib was created.
thebugger as a dev dependency:
npm i --save-dev thebugger # or yarn add --dev thebugger
thebugger() to the line of code you want to start debugging, which is where you'd add a
Wait until your nodejs process prints:
Debugger listening on ws://127.0.0.1:9222/038a3e89-b497-4558-9709-6a3da5ec3803 For help see https://nodejs.org/en/docs/inspector
jest and other wrappers might not show this message but debugger still works on them.
Further instructions at: https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
You also can use any DevTools frontend of your preference, like