7

I am looking for nice console alternative to use with Node.js. I am currently using Console2 but I want some expand/collapse handles when console.log'ing javascript objects; Just like any modern web browser console has (Webkit, Chrome for example).

A remote solution is acceptable. Like a webkit console window remotely connected to a cmd console session.

Must Haves:

  • Collapsible(expand/collapse) objects (and arrays...)
  • Supports colored text goodness
  • Works as a normal console (like Windows cmd). up-arrow, etc
  • Supports copy(ctrl+c), paste(ctrl+v) key shortcuts

Nice to Haves:


Projects I have found:

  • UltraREPL's readme says that collapsible objects are "In Progress".
  • Node Inspector which I thought was perfect but turns out their console is just a REPL client that doesn't print the console.log STDOUT calls in scripts. Node Inspector is really just for inspecting variables and adding breakpoints.
  • Chrome Logger is the closest so far but you need a response object to piggyback which makes this very unusable if you aren't using node as a web server.

Other Questions:

  • I use ConEmu. It does not support collapsible objects, but it's an active project and the developer is open to suggestions. It might be worth submitting one about with that feature – Tymric Sep 26 '14 at 10:04
  • 1
    @Timmy I added a discussion thread on ConEmu about adding the collapsible javascript objects. I found Node Inspector which I thought was perfect but turns out their console is just a REPL client that doesn't print the console.log calls in scripts. Node Inspector is really just for inspecting variables and adding breakpoints. – MLM Sep 26 '14 at 17:45
4

devtool: npm install devtool -g

Runs Node.js programs inside Chrome DevTools (using Electron).

This allows you to profile, debug and develop typical Node.js programs with some of the features of Chrome DevTools.

Use the devtool command in place of node: devtool myscript.js

NodeMonkey: npm install node-monkey

It captures anything that would normally be logged to the terminal, [...] and passes it to the browser where it is then logged to the console for inspection.

This uses Chrome's(webkit) actual built-in Developer Tools Javascript console for output.

  1. Include NodeMonkey in your script: var nomo = require('node-monkey').start({port: 50501});
  2. Open up http://127.0.0.1:50501 and inspect element, etc to open up the developer console.
  3. Then run your script as normal: node myscript.js

One nice thing about NodeMonkey(and node-codein suggested below), is that you can leave up the developer console(no refreshes) everytime you make a change and restart the script, NodeMonkey just continues to listen.

Another thing NodeMonkey has is locations(path, line number, and column), so you know where the message came from (see image below).

I prefer NodeMonkey because it uses the awesome Chrome developer console. Update: devtool is looking to be my new choice.


Iron Node

Debug Node.js code with Chrome Developer Tools on Linux, Windows and OS X.


Inspecting Node.js with Chrome DevTools

This is still in development but you can watch the progress on nodejs/node#2546

The goal is to provide a "unified debugger support across various v8 embedders".

What we aim for Node is what we have for Chrome for Android. You basically go to chrome://inspect on a stable version of Chrome and it debugs your running Node instance.


Mancy: npm install mancy -g

A cross platform NodeJS REPL application based on electron and react frameworks.


node-codein: npm install node-codein

Even though this tool uses the Chrome executable, it does not use the Chrome/Webkit inspector console for output. Instead it uses its own proprietary/special console which feels a bit chintzy.

  1. Include codein in your script: var codein = require("node-codein");
  2. Run path/to/chrome/chrome.exe --app=http://localhost:55281 to open the special node-codein console.
  3. Then run your script as normal: node myscript.js


node-webkit: download build

This is by far the least efficient method to inspect and view console output because of the long list of steps below. node-webkit also has some oddities and changes to the normal Node API which can conflict with your existing libraries or dependencies.

  1. Add a HTML file
  2. Add the script to debug in a <script src="script-to-debug.js"></script> tag to the HTML file.
  3. Update your package.json main attribute to point at the HTML file.
  4. Run nw.exe path/to/project_folder/.
  5. Then wait for node-webkit window to appear.
  6. Click the hamburger icon and wait for th the inspector window (just like Chrome/Webkit) to start, and go the Console tab.
  7. Every time you make a change to your script, go through steps 4-6.

You can also use the remote debugging flag, so you can just pop open a chrome tab and visit the page.

  1. nw.exe --remote-debugging-port=9222 path/to/project_folder/
  2. Visit: http://localhost:9222/
  • Please don't create list answers. Instead separate each program into a separate answer. As it is users cannot upvote/downvote/comment on individual software, and nobody can tell which software you are actually accepting in the answer. – Ken Herbert Dec 15 '14 at 23:23
  • @winterblood NodeMonkey is by far the superior product and I explicitly say "I prefer NodeMonkey". The others do not really deserve their own answer, even if they match the criteria. I only flushed out the other solutions because they exist and work in some fashion. Having all three also shows that I have tried them all and have an opinion and reasons why NodeMonkey is the best and allows me to easily compare between inside of the answer. – MLM Dec 15 '14 at 23:57
1

I use Node Webkit for this. It supports most / all (?) of the Chrome debugging protocols; it also emulates the functionality of Chrome Devtools in terms of inspecting collapsible objects and it supports the same console API calls.

You can even load and inspect modules live from the developer console; which is perfect when getting a feel for the node.js modules you will be using.

Another neat feature that I apply when debugging where I know I will be alternating back and forth between the command prompt is that when using ConEmu, you can embed the Node Webkit DevTools Console directly into a tab in ConEmu. It's seamless and doesn't use much CPU. You can even have it as a split tab with the command prompt so you can see both at once.

  • Can you elaborate on how to set this up? I have ConEmu and embedded NW (I can see the "NODE-WEBKIT" ascii art). How do see the STDOUT output from Node and enter some CMD commands? The devtools console doesn't seem to have this functionality from what I can tell. – MLM Oct 11 '14 at 4:12
  • Depending on what you need to do, it varies. You can connect to the cmd prompt with websockets (you can do this in chrome too), and you can use chrome's remote debugging protocol. When you first open up node-webkit; type process in the devtools console. You get access to the nodejs process object which reveals a lot. Check out these two links for nw debugging help: github.com/rogerwang/node-webkit/wiki/Changes-related-to-node and github.com/rogerwang/node-webkit/wiki/Debugging-with-devtools – dgo Oct 11 '14 at 16:02
  • process.stdin gives "Implement me" error. process.stdout is a stream but I am unable to read/write from it. Entering process.stdout.on('data', function(){ console.log('data'); }); and process.stdout.write('asdf'); does not output data. Running node test-script.js, with console.log calls, in another cmd instance yields nothing. The node-webkit devtools is just for debugging the node-webkit application itself. I have remote debugged before but that is to see the console output on another "system", not to bind the STDOUT/STDIN from a CMD console to the devtools console. – MLM Oct 11 '14 at 17:11
  • 1
    I could be wrong, but I'm 99% sure you can do what you want to do with this. Did you look at the first of the two links I sent? Anyway; If I misunderstood; or gave bad help; I apologize. – dgo Oct 11 '14 at 17:36
  • Please provide specific instructions on how you accomplish this. I have read both links thoroughly and I do not see a solution. – MLM Oct 11 '14 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.