#node-inspector
Explore tagged Tumblr posts
daneastwell · 13 years ago
Link
12 notes · View notes
cjus-blog-blog · 14 years ago
Text
Debugging Node apps with Node-Inspector
Lately I've been playing with Cloud9IDE and test driving the development as a service concept (DaaS). While the Cloud9IDE is far from being bulletproof it's showing signs of greatness. As a comparison I figured I should share how I debug my node app before learning about Cloud9IDE.  I should note that this is still my preferred method.
Enter node-inspector, a tool that allows one to remotely debug node applications directly from a webkit enabled browser (safari/chrome). Unlike Cloud9IDE, node-inspector focuses exclusively on debugging. This isn't a huge issue for me as Komodo allows me to remotely edit files whereby sparing me from edit / deploy cycles.
Let's briefly examine what node-inspector offers.
Tumblr media
In the upper left panel you can navigate source files. In this example, I've set a breakpoint on line 19 in a file called router.js. In the lower panel is the console view. I've typed "map" in order to view the contents of the map variable. The panel on the right also shows variables which are currently in scope. The upper right panel features the call stack which allows you to switch stack frames.
I still get a kick out of debugging client-side using FireBug and server-side using Node-Inspector. As a side note node-inspector is a good way of learning more about the node.js runtime environment.
Getting started with node-inspector is quick and painless.
Installation
First make sure you have the Node Package Manager (npm) installed.
Next, install node-inspector on the machine where your node.js application will run.
$ npm install -g node-inspector
Using node-inspector
Start node-inspector.
$ node-inspector &
Lastly, start your node.js application in debug mode.
$ node --debug server.js
You can then access the node-inspector via your web browser by accessing your machine via the default port of 8080.  Once the page loads you can select the script you'd like to debug. 
Danny Coates the node-inspector creator and maintainer posted a set of getting started videos on YouTube.
10 notes · View notes
epiphanymachine · 12 years ago
Text
debugging Node.js App with Chrome dev tools!
Aug 26th 2013 Updates****
the main branch is the most current again as of Aug 20th 2013
there are also updates to the readme that include a lot what I wrote below:
1. install node-inspector
npm install -g node-inspector
2. don't use port 8080 in your node app (this port is used by node-inspector)***
3. start your app using
node --debug-brk app.js
this starts node in debugging mode with a break at line 1
4. start node inspector
node-inspector
this will output a url, open that url in your browser
5. use chrome debugging tools!!
notes:
you can use debugger or breakpoints as normal
no jasmine-node support...
this main app is no longer supported, and I suggest using the fork linked to above
autorestart node-inspector when you hit an error using these commands:
until node-inspector; sleep 1; done
*** if you want to use port 8080 for your node server you can change the port that node-inspector uses
--web-port=[port] port to host the inspector (default 8080)
**** Updated from:
as of july 2013 this fork is the best: strongloop/node-inspector
Thanks to Jake for posting this code in the comments!
4 notes · View notes
xeektech · 10 years ago
Text
Debugging node.js using node-inspector and Chrome on Mac
Download node-inspector:
Open terminal and type sudo npm install -g node-inspector
Enter the password when prompted
Note: If you encounter this exception: gyp WARN EACCES user “root” does not have permission to access the dev dir then type that command instead:
sudo npm install --unsafe-perm --verbose -g node-inspector
Run your js code with node using the debug-brk param:
node --debug-brk TestWebServer.js
Tumblr media
Open a new terminal window and run node inspector:
node-inspector
Copy the URL
Tumblr media
Open Chrome and run the already copied URL
There you are, Chrome opens up the javascript code you are looking to debug
Tumblr media
Put a breakpoint in the code and issue a request, e.g. http://localhost:3000 and the debugger stops the execution at the breakpoint in the code and you can take it from there
Tumblr media
0 notes