Debugging Node.JS

Node.Js is a simple technology to host a webserver.

I wanted to share the steps to enable debugging on a Windows computer.
To debug  we will use a very powerful tool : node-inspector. Node inspector is a web-hosted debugger which communicates with your application thanks to WebSocket and will allow you to create breakpoints, update your application in live to improve your capacity to solve the issues you can have.

  1. Download and install Node.JS.
  2. Type : npm install -g node-inspector to install node-inspector
  3. Open a first Powershell and type : node-inspector
    This will start a server that you can access by default at : https://localhost:8080/debug?port=5858
  4. Open a second Powershell, go to your application folder and type : node --debug-brk .\app.js
    This will start your application in debug mode.
  5. Go to : https://localhost:8080/debug?port=5858, the application is stopped by default at the start of your app.js application.
    Use the resume button to launch your application
  6. Go to : https://localhost:APP_PORT to access your application

This tool is very powerful and you should be a great help in your projects.