Wednesday, November 6, 2013

Set breakpoint at the first line of code when starting node js application using node-inspector

In order to debug short living node js application, the debugger needs to be attached to the js app and  break on the first line of code, so that the app can be debugged before exiting.

The following command can be used for this purpose

1. From mac's terminal app, starting debugger and the node app
node --debug-brk mynodeapp.js arguments...

for example:
To debug an global npm package, run the application from package's bin folder:
node --debug-brk /usr/local/bin/cordova compile ios

To debug an local npm package, run the js source file
node --debug-brk /usr/local/lib/node_modules/projecteditor/srcib/projecteditor.js -addentitlement /Users/i826633/Documents/SMP3/TestApps/Automation/platforms/ios /Users/i826633/Documents/SMP3/Resource/Common/platforms/ios/MCIM.entitlements

2. start another terminal app and start node-inspector
node-inspector

3. start chrome browser and visit the url of 
http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858
it should break on the first line of the code

Node, in order to edit and save the javascript change from node-inspector debugging, edit file /usr/local/lib/node_modules/node-inspector/config.json to set saveLiveEdit to true as below

saveLiveEdit": true,

For details please refer to
https://github.com/node-inspector/node-inspector


1 comment:

  1. Your blogs are great.Are you also searching for Cheap Nursing Writing company? we are the best solution for you. We are best known for delivering cheap nursing writing services to students without having to break the bank.whatsapp us:+1-(951)-468-9855

    ReplyDelete