Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with compiling projects with nexe that use winston #1484

Closed
1 of 2 tasks
Trivernis opened this issue Sep 27, 2018 · 9 comments
Closed
1 of 2 tasks

Problem with compiling projects with nexe that use winston #1484

Trivernis opened this issue Sep 27, 2018 · 9 comments

Comments

@Trivernis
Copy link

Trivernis commented Sep 27, 2018

Please tell us about your environment:

  • winston version?
    • winston@2
    • 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.

@DABH
Copy link
Contributor

DABH commented Sep 28, 2018

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!

@DABH DABH closed this as completed Sep 28, 2018
@Trivernis
Copy link
Author

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.

@RPDeshaies
Copy link

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

@MichaelHirn
Copy link

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

@nicolas-marien
Copy link

@MichaelHirn I found the solution here quite useful

@NikolaNikushev
Copy link

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.

@anweiss
Copy link

anweiss commented May 7, 2021

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.

@Huespal
Copy link

Huespal commented Aug 11, 2021

I have this problem when running my project having a third party library that uses winston internally.
Third party lib is bundled using esbuild. The other one uses webpack.

There's a way to bypass the error?
I use Yarn Berry (v.3 now, I think), with pnp, so no node_modules available.

Any help is appreciated.
Thank you.

@MaRuifeng
Copy link

I encountered perhaps the same issue, but in a different context. Bumped into error Cannot find module ‘./combine.js’ after building my Lambda function using esbuild. I found this issue logform library uses non-string literals in require and fails at runtime, but works with webpack, and the verified fix for me was to upgrade the winston logger to a newer version, that takes in this fix from logform to avoid dynamic requires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants