środa, 24 października 2012

Debugging Node.js project under Windows

What is required to debug a Node.js project under Windows.

1) Installing node-inspector
- command line:
npm install -g node-inspector

2) Starting Node.js application AND node-inspector in the same time:
- assuming: app.js is a node.js application
- command line script (e.g. start.bat):
Taskkill /IM node.exe /F
(start /B node-inspector ) && (start /B node --debug app.js)
pause


3) Checking out the result:

- assuming:  app.js starts at port 3000;
- node-inspector prints out IP and PORT
- for the webapp browse to:
127.0.0.1:3000
- for debugger browse to (default values):
http://127.0.0.1:8080/debug?port=5858