First step is to always use at least the latest LTS version of Node (8.x).
Next get acquainted with how to run your process without npm or yarn, for you will need to be able to run it with node process flags. For example, for looking-glass we start our server using an index.js
file in the root of the project. So instead of running yarn start
, we would run node index.js
.
Now by default node doesn't have the "inspector" on in the process. You have to turn it on and there are a couple ways to do that. First, and the most common, is to pass a flag to the command; node --inspect index.js
or node --inspect-brk index.js
. Next, you can activate it by sending a SIGUSR1
to the running process; kill -s SIGUSR1 <pid>
If you have successfully entered debug mode, you will see some output to your stdout:
$ node --inspect .
Debugger listening on ws://127.0.0.1:9229/f3f6f226-7dbc-4009-95fa-d516ba132fbd
For help see https://nodejs.org/en/docs/inspector
Something to note about that url in the output. It's a websocket and Chrome supports ws://
as a protocol that can be navigated to.
At this point you have activated the debugger in node, it will remain in this mode until killed. This is important to remember if you are debugging a production instance of node, for you do not want to run the process in inspect mode in production.
chrome://inspect
(Too much to write here)