Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output to Chrome console from Node.js

Tags:

I'm looking for a way to output Node variables directly into the google chrome browser console. The same way a console.log() works on the client side. Something like this for php. This would greatly speed up development.

like image 873
ThomasReggi Avatar asked Jul 28 '12 20:07

ThomasReggi


People also ask

How do I use console in node JS?

Unit Testing and Test Driven Development in NodeJS Node. js console is a global object and is used to print different levels of messages to stdout and stderr. There are built-in methods to be used for printing informational, warning, and error messages.

How do I inspect node js in Chrome?

Using Google Chrome DevTools to Debug The next step is to head to Chrome, open a new tab, and enter the URL chrome://inspect/ . Click on “Open dedicated DevTools for Node” to start debugging the application. It will take a couple of seconds to view the source code in Chrome DevTools.


2 Answers

NOTE: Since the old answer (written in september 2014) refers to an older version of node-inspector, my instructions are not relevant anymore in 2017. Also, the documentation has gotten a lot better, so I have updated my original answer:

node-inspector is what you need. It opens up an instance of Chrome with its developer tools for debugging.

It's also easy to use:

1. Install

$ npm install -g node-inspector 

2. Start

$ node-debug app.js 

Source: https://github.com/node-inspector/node-inspector

like image 58
Nahn Avatar answered Sep 24 '22 14:09

Nahn


You might want to try NodeMonkey - https://github.com/jwarkentin/node-monkey

like image 38
honzzz Avatar answered Sep 24 '22 14:09

honzzz