This is the fourth blog post in our series around developing a node.js application using Monaco. In this part you will learn how to debug your node.js applications using node-inspector.
If you are interested in other parts of this series, please use the links below:
- Part 1: Introduction
- Part 2: How to configure the workspace for IntelliSense
- Part 3: Using Mocha for server side unit testing
- Part 4: How to debug node.js applications on Azure
- Part 5: How to connect to an existing workspace using source control
- Part 6: Best practices leveraging development and production sites
How to enable node-inspector for debugging
Open our web.config and find the <iisnode> element to add the following attribute:
Then restart the application (Ctrl+F5) and open the following URL in your browser: http://<sitename>.azurewebsites.net/app.js/debug/ (if your Azure web site is called “monacotesting”, the resulting URL would be http://monacotesting.azurewebsites.net/app.js/debug/). If you take a look into the web.config file you will notice some rewriting rules. One of them is responsible to support node inspector. The web.config file is automatically generated for you once you run your application out of Monaco. The <iisnode> element can be used to configure some interesting development settings. You can read about all the available options here.
You will find yourself inside node-inspector and you can start adding a breakpoint and debugging your express application. Once you are done debugging, it is recommended to change the configuration in web.config back to “false”. You can also navigate to http://<sitename>.azurewebsites.net/app.js/debug?kill. This will terminate the debugger and debugee processes in Azure.
Note that node-inspector is known to work best in Chrome as browser.
If you are interested in a video with step by step instructions for enabling debugging in Monaco, you can also check out our video on Channel9 on this topic.
In this part of the series you have learned how to enable node-inspector from Monaco to debug your node.js application. Stay tuned for the next part where you will learn how to use source control with Monaco and work with development and production web sites.