nw.js: node-main: errors and console.log not redirected to webkit console

tested with nw version: 0.8 and 0.9.2 on windows

We had errors in our script that is used as node-main. Unfortunately neither the errors nor console.log appeared in the webkit console. Not even in the terminal.

We could only retrieve the errors by logging them to file, having a big try/catch block around everything.

Apart from this bug, I would propose two new options for package.json, one for logging everything (errors, console.whatever from windows and node-main) to a log-file and one for logging everything to the terminal.

Thanks a lot. Great tool! 😃

p.s. Linux shows errors in terminal (on windows nw seems to create a child process)

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

you may try process.stdout.write(util.format.apply(util, arguments));

which would look like

var console = (function(){
    var util = require('util');
    return {
        log:function(x){
            process.stdout.write(util.format.apply(util, arguments));
        }
    }
})()
//...
console.log('test', {whatever:'test'})

I cannot get any of the proposed work arounds to work in 0.13.1. Is there anyway to output to STDOUT or STDERR messages for debugging node-main scripts?

I have temporary 2 solutions to output logs on terminal.

  1. Util - http://nodejs.org/docs/latest/api/util.html#util_util_format_format
var util = require('util');
util.log('log message');
util.log(util.inspect({'test': 'test'}));
  1. Log module - https://www.npmjs.org/package/log
var Log = require('log')
  , log = new Log('debug');

log.info('sending email', {'test': 'test'});
log.error('failed to send email');
log.debug('preparing');

Hope that helps.