winston version?_winston@2winston@3 node -v outputs:_ v8.11.3When 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.
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)
...
There's been a similar problem that was fixed with a newer release of winston. #178.
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.
Most helpful comment
FYI: this error is also triggered when using Parcel (http://parceljs.org) with the
--target nodeflag.I still haven't found a way to fix that in my case