Log out to the Chrome console with Node.js

I'm looking for a way to output Node variables directly to the Google Chrome browser console. Similarly, console.log() works on the client side. Something like this for php . This will greatly accelerate development.

+19
google-chrome console
Jul 28 '12 at 20:10
source share
7 answers

NOTE. Since the old answer (written in September 2014) refers to the older version of node-inspector , my instructions are no longer relevant in 2017. In addition, the documentation became much better, so I updated my original answer:

the inspector node is what you need. He opens a Chrome instance with his developer tools for debugging.

It is 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

+21
Nov 05 '13 at 10:29
source share

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

+5
Aug 19 '13 at 16:53 on
source share

The closest I've seen to this is Node JS console object debug inspector

See this post for usage and potential issues: http://thomashunter.name/blog/nodejs-console-object-debug-inspector/

+3
Jul 28 '12 at 20:17
source share

For users with nodejs on linux via ssh-shell (putty):

The problem with nodejs in linux-ssh-shell is that you do not have a connected browser. I tried all these solutions, but did not get it to work.

So, I developed a solution with firebase ( https://firebase.google.com ), because my project uses firebase. If you are familiar with firebase, this is a great way. If not, firebase should be used in conjunction with nodejs - and its free!

In the server side of the script (starting with node) use your own function log ():

 // server-side: // using new firebase v3 ! var fbRootRef = firebase.database(); var fbConsoleRef = fbRootRef.ref("/console"); var log = function(args) { fbConsoleRef.set({'obj': args}); } // inside your server-code: log({'key':'value'}); 

On the client side, you create a link to firebase on this console object:

 // client side: fbRootRef.child('/console').on('value', function(d) { var v = d.val(); console.log(v); }); 

Now everything registered on the server side with the log () function is transferred in real time to the firebase database and from there they launch the client console link and register in the browser console.

If someone needs help, I will explain in more detail and can provide a more advanced version of this logging using the types (console./log/warn/info), grouping header information (for example, the server says: (file name + line).

Configuring firebase for your project takes a maximum of 30 minutes by inserting a console function after 30 minutes. I think it is worth the time.

+2
Jun 21 '16 at 23:24
source share

I know this is an old question, but it was at the top of my google search, so maybe someone will find my answer helpful.

So you can use node --inspect-brk index.js

Now all you have to do is just type chrome://inspect in the Chrome address bar and click Open dedicated DevTools for Node

In DevTools, now connected to Node, you have all the Chrome DevTools features you used to:

  • Full debugging of a breakpoint, step-by-step execution with a black box

  • Source maps for the transferred code

  • LiveEdit: Evaluating JavaScript Hot Swap with V8

  • Console evaluation with support for ES6 features / objects and custom object formatting

  • Custom Flaming Chart JavaScript Profiler

  • Heap snapshot verification, heap distribution graph, distribution profiling

  • Asynchronous Stacks for Native Promises

Hope this helped.

+1
Jun 26 '18 at 10:19
source share

This is a great video I found on Andrew Mead, How to debug code in VSC and the Chrome browser.

You tube link

0
Mar 01 '18 at 7:09
source share

You can use bonsole , an easy way to log in to the browser. Even on Linux, you can log in to the ip of the local network to check this.

0
Jul 14 '19 at 0:03
source share



All Articles