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?