electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.73k stars 1.74k forks source link

electron-builder@25 crashes if electron-builder.env exists #8451

Closed Dozorengel closed 2 months ago

Dozorengel commented 2 months ago

If there is electron-builder.env (even empty), any build command throws an error with the following stacktrace:

❯ npx electron-builder
  ⨯ require(...) is not a function  failedTask=build stackTrace=TypeError: require(...) is not a function
    at loadEnv (/Users/dozorengel/projects/glabix-screen-recorder/node_modules/read-config-file/src/main.ts:140:27)

If I delete this file, build is working fine. The latest working version is 24.13.3

mmaietta commented 2 months ago

I'll take a look at this asap. There's other issues appearing with the updated dependency read-config-file, so I may have to just copy the logic directly into electron-builder for more control of the implementation.

Looks like it's failing at this line

require("dotenv-expand")(parsed)
mmaietta commented 2 months ago

Quick note: I've extracted read-config-file into electron-builder, updated dotenv-expand in this PR https://github.com/electron-userland/electron-builder/pull/8455 and was unable to reproduce the issue, so hopefully that was just a simple fix.

emeryao commented 2 months ago

+1 same here

mmaietta commented 2 months ago

This should be fixed in electron-builder 25.1.2, can you please give that a shot?

emeryao commented 2 months ago

electron-builder@25.1.2 works fine with .env file for my project 👍