

The cluster module fixes this for you.īecause you want to debug these more complex situations where your Node.js application server is running a master process and multiple child/worker processes, we will use the technique above to run each process on it's own inspect port. Modify the "program" property to the filename you want to launch and debug ("program": "$) Īs each child process has it's own debug port, you'll no longer get "Unable to open devtools socket: address already in use" errors when forking child processes with debugging options.įYI, if you use the Node.js cluster module in your applications, each forked worker will get it's inspectPort incremented automatically. You'll see a "launch.json" file is created and select "Node.js: launch program":


You'll notice we need to define a debug configuration first (at the top, click on "No configurations" and select "Add configuration". We will start with basic debugging using a very small test.js file and go to the debug view: When you are developing applications using an IDE like Visual Studio Code, you can very easily debug your Node.js process:įirst, download the free Visual Studio Code and install it on your development machine. Because of the asynchrnous nature, a standard Node.js application server works single-threaded by default. One of the most important features during application development is the ability to debug your code easily.
