nexe: No such native module with winstonjs/winston

I get this error when I run the compiled application.

nexe.js:1129
    var doParallelLimit = function(limit, fn) {
                            ^

Error: No such native module ./transports/console
    at NativeModule.require (node.js:932:13)
    at s (nexe.js:1:176)
    at nexe.js:1:367
    at Object.Console (nexe.js:66028:12)
    at new exports.Container (nexe.js:65162:29)
    at Object.__dirname.259../winston/common (nexe.js:64514:19)
    at s (nexe.js:1:316)
    at nexe.js:1:367
    at Object.__dirname.175.events (nexe.js:47558:15)
    at s (nexe.js:1:316)

The file that might be triggering the error is https://github.com/winstonjs/winston/blob/0.8.3/lib/winston/transports.js#L32

I tried the following to workaround the dynamic requires:

In the file where I call nexe.compile(), I added a code before that to create a file on the same directory as transports.js. The file contains:

require('./transports/console');
require('./transports/daily-rotate-file');
require('./transports/file');
require('./transports/http');
require('./transports/memory');
require('./transports/transport');
require('./transports/webhook');

Then that file is required at my main file:

var _nexeDynamicBundle = false;

if (_nexeDynamicBundle) {
  require('winston/lib/winston/nexe-bundle');
}

And also, the generated binary file contains the required files as what I saw in output.exe/.rdata:

},{"./common":260,"fs":undefined,"path":undefined}],270:[function(require,module,exports){
/*
 * console.js: Transport for outputting to the console
 *
 * (C) 2010 Charlie Robbins
 * MIT LICENCE
 *
 */
},{"./transports/console":270,"./transports/daily-rotate-file":271,"./transports/file":272,"./transports/http":273,"./transports/memory":274,"./transports/transport":275,"./transports/webhook":276}],269:[function(require,module,exports){

Any idea why the error occurs?

About this issue

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

Most upvoted comments

The issue disappeared for me after upgrading to the latest winston.