EzDevInfo.com

node-inspector

Node.js debugger based on Blink Developer Tools

Using node-inspector with Grunt tasks

Does someone used node-inspector with Grunt for application debugging? If not, Can you recommend a debugging tool for Grunt based apps?

I'm working with nodejs for a server side app and I have Grunt to use separated tasks (this is because users can execute tasks separately).

Thanks in advance


Source: (StackOverflow)

debugging node.js with node-inspector

I'm trying to debug my nodejs app using node-inspector. But Google Chrome doesn't show the code.

I'm using the following,

Node.js : v0.10.26

Express : 4.0.0

Node Inspector : v0.7.3

Google Chrome version : 34.0.1847.131

This is what I'm doing to start the debugger..

$ node-inspector
Node Inspector v0.7.3
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

In another console,

$ node --debug app.js 
debugger listening on port 5858
$

Then started Google Chrome and went to

http://127.0.0.1:8080/debug?port=5858

It opens up node-inspector but without any code..all windows are empty.

Noticed that I'm not getting 'Express server listening on port 3000'

Tried all as per node-inspector fails to connect to node but no luck

Couldn't work out what I'm missing. Would be great of you have any suggestions..so I can debug my Node.js apps in Google Chrome.


Source: (StackOverflow)

Advertisements

How can I make node-inspector restart when node is restarted?

I use node-inspector a lot. When I edit my code and restart, I get the inevitable

Detached from the target

Error when a new process starts. I always have to go find the tab node inspector is on and restart it.

I was wondering if I could avoid this. For example, send a message to node-inspector from node to tell the browsers tab running node-inspector to restart.


Source: (StackOverflow)

Node inspector doesn't start

I run NodeJS Express server on 127.0.0.1:3000 and trying to debug it with awesome (when it works) Node Inspector but having trouble starting it after the update. I used to run version of Node Inspector 0.7.4 with node-debug server.js with no problems. Then I wanted to update it to latest 0.10.0 and went npm update -g node-inspector but now when I run node-debug server.js blank page opens in browser with url http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 and nothing happens. I tried node-debug --web-host=127.0.0.1:3000 with no luck.

How can I debug my my Node programs now? BTW I'm on Ubuntu.

EDIT: I had no luck running latest version 0.10.0 so I had to uninstal and install 0.9.2. Node inspector started with no problem then. I run 0.10.0 on my mac but on Ubuntu it doesn't seem to work for some reason so going back to 0.9.2 was only solution. I hope this will help some Ubuntu users.


Source: (StackOverflow)

Running node-inspector and node-debug with npm run

How to run two script at once with npm run? First of all I know grunt or gulp but I want to make it without another js modules. To make this I have this script:

"scripts": {
  "start": "node ./node/www",
  "nodemon": "./node_modules/.bin/nodemon node/www.js -i './e2e-tests/**' -i './node_modules/**' -i '.idea/**' -i './node/log/**' -w './node/server/**/*' -V -L",
  "nodeInspector": "./node_modules/.bin/node-inspector --save-live-edit=true",
  "debug": "node-debug ./node/www.js",
  "ins": "npm run nodeInspector & npm run debug"
}

I want to run with npm run ins but it only fires node-inspector. enter image description here


Source: (StackOverflow)

In debug mode, mocha doesn't stop on debugger statements in a spec file when using node-inspector

When I run mocha with --debug-brk and open chrome dev tools with node-inspector, the debugger skips over any debugger statements that I put in my specfile.

I can get debugger statements to work in module files provided I follow this trick of placing a breakpoint at the bottom of the mocha lib.

Has anybody else seen this problem?


Source: (StackOverflow)

Installation of node-inspector?

node-gyp-rebuild-2-builderror-log 

this error is coming continuously even after trying

npm install node-gyp -g

how to solve this and install node-inspector properly.

enter image description here


Source: (StackOverflow)

Using Node Inspector with multiple node processes

I started using Node Inspector to debug some of my Node applications. However, one thing i am not sure how to do is, once Node-inspector is attached to one Node app, how to detach and attach it to another Node app running on same box?

can i attach to multiple processes at the same time?


Source: (StackOverflow)

How to debug node js app with breakpoints and everything?

I've installed node-inspector just to find out that it doesn't support breakpoints :| What's the point in it at all, bearing in mind that on big part node code is asynchronous and you simply cannot follow it step by step?..

I'm definitely missing a point here...

Anyway to debug node code with breakpoints and everything?


Source: (StackOverflow)

Debugging Gulpfile with node-inspector takes long to start

I am trying to debug my gulp taks with node-inspector by running it like this

node-debug $(which gulp) build

and that works, except my Gulpfile is not .js but .coffee and for some reason it hangs for almost a minute in the beginning saying:

Requiring external module coffee-script/register

It doesn't take that long when I run it normally and it starts node-inspector almost instantly if I use Gulpfile.js. Why is it taking too long when I use Gulpfile.coffee?

It's not a big deal, yet a bit annoying


Source: (StackOverflow)

Hard to set up breakpoints in Node-Inspector

I have setup a web application that works and now I want to learn how to debug it properly without using console.log. I have setup and ran Node-Inspector via node-debug server.js (main script file) and I want to use and check what happens when I set up a breakpoint for an example in the following post function.

.post('/login', function (req, res){
    var user = {
        username: req.body.username,
        password: hash(req.body.password)
    };
    db.findOne(user, function (err, data) {
        if (data) {
            req.session.userId = data.id;
            res.redirect('/');
        } else {
            res.redirect('/login');
        }
    });
})

Node inspector works nicely and i'm familiar with it's design since using Google Chrome developer tools for basic JavaScript debugging (jQuery etc.) for some time. Everything looks good until I try to login into an application. Instead of breaking in for an example "var user" line it simply jst jumps into "timer.js" file in somesort of an setImmediate function. Even when i try to jump over i never get to that breaking point where I wish to see what does the post function contain inside a req, res variables etc.

I'm using NodeJS v0.12.2 and node-inspector 0.10.0.

I'm using body-parser, bourne, express and express-session modules in the project. Maybe worth mentioning that i'm running application on different port than 8080 or 5858 and I also have the specified code in another .js file if that may be somehow the case, since i can successfully breakpoint the first few (require) lines of the main server js file.

I don't know what to do or how to breakpoint a simple if statement wherever is stated. It just simply goes to somewhat timers.js and few step-overs it's done.

Any idea why is this happening?

Thanks in advance.


Source: (StackOverflow)

Can't get node-debug to work

This feels really silly, but I can't get node inspector / node-debug to work.

The instructions say to do npm install then to run node-debug web.js. So I did that. Now I have a lovely browser window open showing me my code with breakpoints... and no idea which url to use to actually access the code.

The inspector is at http://localhost:8080/debug?port=5858 and the terminal says:

> node-debug web.js
debugger listening on port 5858
Node Inspector is now available from http://localhost:8080/debug?port=5858
Debugging `web.js`

...

I've tried hitting up localhost:5000 (which is my express.js port) but that either fails if I don't have a separate node web.js instance running, or it succeeds if I have the other one running but doesn't trip any of the breakpoints in the inspector.

When I go to http://localhost:5858/, I get:

Remote debugging session already active

When I go to http://localhost:8080/, I get:

Cannot GET /

(the / path totally works on my server in general.)


Source: (StackOverflow)

sails debug command not working in Sails.js

I am creating my first sails.js app. When I tried

sails debug

I'm getting the following error on my command prompt

Debugger listening on port 5858
info: Starting app...

error: Grunt :: Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Agent.Server._listen2 (net.js:1129:14)
    at listen (net.js:1155:10)
    at Agent.Server.listen (net.js:1240:5)
    at Object.start (_debugger_agent.js:20:9)
    at startup (node.js:86:9)
    at node.js:814:3

To get the PID of the process using port:5858, I tried running

C:\Windows\system32>netstat -a -n -o

but unfortunately there is no process bound to port 5858. Am I missing something here?

I'm using Windows 8.1 with node.js v0.12.0 and sails.js 0.11.0


Source: (StackOverflow)

Cannot set breakpoint inside function when using require inside closure

Using node-inspector, I'm unable to set breakpoint in the following node.js code. (Content of main.js)

(function() {
    require('underscore');

    var doSomething = function(callback) {
        callback('doSomething Finished');
    }

    doSomething(function(x) {
       console.log(x);
    });

}).call(this);

I can easily set a breakpoint on line 2, line 4 or line 8, however no matter how hard I try the debugger won't let me set a break point on line 5 or line 9. To be clear, I'm using the following commands to run node-inspector

node --debug-brk main.js
node-inspector

I also tried to debug in web storm, however the issue persists. If I remove the line require('underscore');, then the problem immediately goes away and I'm able to set break point inside function body again. The problem also goes away if I remove the outermost closure function. It seems that the interaction between require and file level closure is screwing up the node debugging functionality. Has anyone experienced this problem themselves and / or knows any workarounds to be able to break inside function body?

EDIT: My node js version

Tony:~ $ node --version
v0.10.12
Tony:~ $ 

Source: (StackOverflow)

How to debug and log own code on the server side of Meteor?

Never mind. The reason this did not work: I forgot to meteor reset so debugger did not get a chance to stop. Duh!

More info: I am using the method in the answer by Mason Chang to the related question, not the kill -s USR1 [proc_id] (where I could see the scripts, but not able to stop in the startup() function.). Also, I am using meteorite.

I am trying to debug the Meteor.startup(function ()) code on Meteor server side (i.e., under /server) with node-inspector, I have read this question, and following the answer to change run.js, but somehow, my own script for the startup function does not show up in the scripts section of Chrome.

How do I see my code here and set break points and stop at those points? BTW, the Meteor_debug() does not output anything to stdout, stderr, or node-inspector browser console. I also tried console.log() with no avail. How to enable logging on Meteor server side?

If it matters, I am on auth branch.

The code here is very simple (/server/bootstrap.js):

Meteor.startup(function () {
 if (Logs.find().count() === 0) {
  var data = [/*...some data...*/];
  var timestamp = (new Date()).getTime();
  Meteor._debug("timestamp: "+timestamp+", data.len: " + data.length);
  debugger;
  for (var i = 0; i < data.length; i++) {
    data[i].timestamp = timestamp++;
    var entry_id = Logs.insert(data[i]);
    Meteor._debug("entry_id: "+ entry_id);
  }
 }
});

Source: (StackOverflow)