2

I have been seeking solutions for debugging Node.js based web application from days. I had tried to debug with Eclipse + Chrome debugger plugin but failed, I posted the error in this session 'Failed to get tabs for debugging' when trying to debug NodeJs with chrome debugger for Eclipse, but could not find an answer.

However, as Node.js is so popular, I have no doubt that a lot developers have the solution for debugging Node.js server JavaScript code. I appretiate if you could share me your solution of setting up an IDE (edit and debug) for Node.js server JavaScript code, or at least how to debug it.

3 Answers 3

1

I would suggest using node-inspector. Here is a good tutorial for setting it up. It allows you to use a browser tab to look at your code, set breakpoints, and step through it. Additionally, you can start node with the flag --debug-brk and it will insert a break point on the first line, if you need to debug something that happens on startup.

Sign up to request clarification or add additional context in comments.

2 Comments

it is said node-inspector is no longer supported? github.com/dannycoates/node-inspector/issues/126
@Shuping It looks like it, and the profiling doesn't work. But I've never had any trouble with it for debugging.
1

There are several tools to debug a node application. A great ressource has been postet on Github recently.

A simple debugging setup might be just adding a breakpoint to your code and start node in debug mode like this:

Example code with use of debugger, a manual breakpoint.

app.get('/foo', function(req, res) { var something = 123; debugger; // execution stops if this point is reached foo(something); }); 

Start node in debug mode:

$ node debug app.js 

Once you started the application in debug mode you use the application (e.g., navigate to the ressource with your browser) and once a breakpoint occurs, the execution stops and you have a debugger environment in your terminal.

3 Comments

From the link, for debugging on Ubuntu seems the only option is 'Node Webkit Agent'. Does it support to add break points to pause application running on chrome browser dev tools? I did not see this information in the link.
Although that is titled "Debugging & Profiling Node.js", all of the steps are actually about profiling.
Before executing the app open the inspect element of the browser.
0

Try to use Weinre (WEb INspector REmote). It's a node app help you debug UI, log for web app on devices. It hope it can help you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.