Winston: Problem with compiling projects with nexe that use winston

Created on 27 Sep 2018  路  7Comments  路  Source: winstonjs/winston

Please tell us about your environment:

  • _winston version?_

    • [ ] winston@2

    • [x] winston@3

  • _node -v outputs:_ v8.11.3
  • _Operating System?_ Windows
  • _Language?_ ES6/7

What is the problem?

When I compile a project that uses winston with nexe project.js -o project.exe and use the integrated formatters, I get the error Cannot find module './format' or Cannot find module './combine.js'. When executing the project.js file directly everything works fine. The nexe compiling process didn't show any errors.

Other information

Stacktrace

javascript Error: Cannot find module './combine.js' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) ...

Related

There's been a similar problem that was fixed with a newer release of winston. #178.

Most helpful comment

FYI: this error is also triggered when using Parcel (http://parceljs.org) with the --target node flag.

I still haven't found a way to fix that in my case

All 7 comments

nexe probably doesn't like the dynamic requires in logform. Webpack detects browser in https://github.com/winstonjs/logform/blob/master/package.json and uses the browser-safe version instead (no dynamic requires). If nexe could do the same, your error would most likely go away. But that is probably a question for the nexe folks, whether it's possible to specify to prefer browser fields like webpack over main fields. Let us know if you figure something out, could be good for documentation!

My Solution/Workaround

#

Just don't use nexe. Use pkg instead.
I used nexe because it makes it easy to include additional resources (e.g. JQuery, vuejs) in your executable. This works with pkg too but is a bit tricky.

FYI: this error is also triggered when using Parcel (http://parceljs.org) with the --target node flag.

I still haven't found a way to fix that in my case

@RPDeshaies have you found a solution to the problem? I ran into the same issues

@MichaelHirn I found the solution here quite useful

I had the same issue and I was importing the following:

import { createLogger, transports,format } from "winston";

I changed the import for format to

import { format } from "logform/dist/browser";

and that solved it for me.

I am using https://parceljs.org/ for packaging a lambda.

FWIW, I'm still running into this issue, but after using browserify to bundle a library that has a dependency on winston. I'm using the --node flag with browserify. Cannot find module './combine.js' is the error I'm hitting.

Was this page helpful?
0 / 5 - 0 ratings