2

I am playing with Node.js and eclipse using nodeclipse (here) using a newly installed eclipse instance. I've had passing experience with eclipse, but this is a new install for this purpose. I've been using Node.js for a while but I wanted to see what eclipse can add to my headaches (or hopefully relieve (some of?) them!). Node --version v0.10.22 Eclipse version is Version: Kepler Service Release 2 Build id: 20140224-0627.

Ok, so I created a new project with New > Other.. > Nodeclipse > Node.js Express Project. Gave it a name of Hello World and took the defaults. I updated the index.js file to add some interesting things to add breakpoints to:

exports.index = function(req, res){
  res.render('index', { title: 'Express' });
  console.log( "here" );
  var i=45;
  i = i+3;
  console.log( i );
};

And I put a breakpoint on that i = i+3 line. I've tried Run, Run As > Node Application and it doesn't stop at my breakpoint when I hit "mylclhost:3000" from my browser. If I do Debug As > Nodejs Application, it shows a new panel with a blue chrome favicon, (similar to what this guy states happens), hitting mylclhost:3000 results in a 404, so I hit F8 to continue and mylclhost:3000 works as expected but no breakpoint hits.

This is my Nodeclipse console output after Project Explorer > Right click app.js > Debug As > Node Application: node --debug-brk=5858 C:\Users\person\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js C:\Users\person\workspace\HelloWorld\app.js --tea-pot-mode

This is the normal console output after I hit F8 to continue after the first breakpoint (Notice that Nodeclipse by default enters step-by-step debugging mode from very first line):

debugger listening on port 5858
21 Mar 09:58:38 - [33m[nodemon] v1.0.15[39m
21 Mar 09:58:38 - [33m[nodemon] to restart at any time, enter `rs`[39m
21 Mar 09:58:38 - [33m[nodemon] watching: *.*[39m
21 Mar 09:58:38 - [32m[nodemon] starting `node C:\Users\person\workspace\HelloWorld\app.js --tea-pot-mode`[39m
Express server listening on port 3000

I then point my browser to lclhost:3000 and get a success page, the normal console reports:

.... other stuff....
Express server listening on port 3000
[90mGET / [36m304 [90m234ms[0m
here
48
[90mGET /stylesheets/style.css [36m304 [90m4ms[0m

The relevant code with the breakpoint (marked as *):

exports.index = function(req, res){
  res.render('index', { title: 'Express' });

  console.log( "here" );
  var i=45;
 *i = i+3;

  console.log( i );

};

You can see it prints the "48" in the console and skips the breakpoint entirely.

Like I said, this is a new install so the post linked above isn't really helpful. I suspect this has to do with the asynchronous nature of Node.js, but it seems like other people have successfully gotten this to work.

Any ideas, or anything I am missing?

Community
  • 1
  • 1
nomadic_squirrel
  • 614
  • 7
  • 21
  • Instead of New > Other.. > Nodeclipse > Node.js Express Project. switch to Node perspective. Also I monitor SO questions with `nodeclipse` tag, but it was missing. http://www.nodeclipse.org/#support – Paul Verest Mar 20 '14 at 02:19

2 Answers2

2

You can try running node --debug-brk=5858 app.js in the command window and then start eclipse debugger on the file.That worked for me. I am using Enide Studio 2014.

-3

Take time to learn more things.

You seem have not read even http://www.nodeclipse.org home page, references how to get support http://www.nodeclipse.org/#support

Run As > stats Node.js in non-debug mode, so of course it would not stop.

Instead of New > Other.. > Nodeclipse > Node.js Express Project switch to Node perspective.

See also Nodeclipse debugger ignoring breakpoints

If the problem is still there, raise an issue giving information again mentioned in http://www.nodeclipse.org/#support

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • Ah, yes, Run As got it. But as noted, I did Debug As and it hits some random breakpoint, but ignores my other breakpoints. I did find the "Node" perspective, but when I do Run > Debug I am asked "This kind of launch is configured to open the Debug perspective when it suspends" and I am brought back to the Debug perspective, which seems to have all the info I need if it would stop at my breakpoints. – nomadic_squirrel Mar 21 '14 at 16:37
  • ok, so the enter button sends the comment... noted... I'm sure this is more of user error than a bug. I'm not seeing that `debug-brk=5858` parameter in my console, so I'll dig around to figure out how to add that and post back. – nomadic_squirrel Mar 21 '14 at 16:40
  • Post updated. You can see the debug-brk in the console output now. I'm not sure where to take this now? – nomadic_squirrel Mar 21 '14 at 17:17