forge icon indicating copy to clipboard operation
forge copied to clipboard

Electron Forge resolving path to node module using absolute path rather than using relative path in production

Open ec2-learn-instant opened this issue 1 year ago • 7 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.4.0

Electron version

30.5.0

Operating system

Windows 10

Last known working Electron Forge version

No response

Expected behavior

I'm trying to create an app that include the get-windows npm package, it's properly working in development mode. After I make production build, it throws error, reason beacuse its takes the development path in production build

Actual behavior

[error] (node:13140) UnhandledPromiseRejectionWarning: Error: D:\VMKV\electron-app\node_modules\get-windows\package.jsondoes not exist at t.find (C:\Users\Quick App Studio\AppData\Local\Programs\my-electron-app\resources\app.asar.webpack\main\index.js:2:3391) at p (C:\Users\Quick App Studio\AppData\Local\Programs\my-electron-app\resources\app.asar.webpack\main\index.js:2:1654721) at m (C:\Users\Quick App Studio\AppData\Local\Programs\my-electron-app\resources\app.asar.webpack\main\index.js:2:1654862) at Module.n (C:\Users\Quick App Studio\AppData\Local\Programs\my-electron-app\resources\app.asar.webpack\main\index.js:2:1649771) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async App. (C:\Users\Quick App Studio\AppData\Local\Programs\my-electron-app\resources\app.asar.webpack\main\index.js:2:13148557)

Steps to reproduce

Also note, I am using the following versions:

Node: 20.16.0 Electron: ^30.5.0 electron-forge/cli: ^7.4.0 get-windows: ^9.2.0

Please let me know if there's any missing info.

Additional information

No response

ec2-learn-instant avatar Sep 11 '24 07:09 ec2-learn-instant

#3209 probably related

rtritto avatar Sep 11 '24 16:09 rtritto

I have this issue too. I am not sure why it takes the absolute path rather than the relative path. Same exact package too oddly enough. If anyone finds a work around, please leave it here!

bearsworth avatar Nov 09 '24 11:11 bearsworth

Same package, same issue, @electron-forge/cli": "^7.5.0

bukacdan avatar Dec 05 '24 09:12 bukacdan

Hey, I'm unable to reproduce this issue out of the box with a fresh installation of Forge + the get-windows directry.

Here's my repro code:

https://github.com/erickzhao/electron-forge-repros/commit/56e57784f3345196a185c4008eea3a02c5e09132

Here's a screenshot of it working for me:

Image

If someone could provide additional reproduction parameters, that'd be really helpful. Maybe it has to do with package managers as @rtritto mentioned? I'm currently using Yarn Classic.

erickzhao avatar Jan 31 '25 05:01 erickzhao

Hey, I'm unable to reproduce this issue out of the box with a fresh installation of Forge + the get-windows directry.

Here's my repro code:

erickzhao/electron-forge-repros@56e5778

Here's a screenshot of it working for me:

Image

If someone could provide additional reproduction parameters, that'd be really helpful. Maybe it has to do with package managers as @rtritto mentioned? I'm currently using Yarn Classic.

I think it’s because you have a different operating system from the issue. Try it on Windows.

bearsworth avatar Jan 31 '25 11:01 bearsworth

Hey @bearsworth, thanks for the response. My tester code also compiled for me on Windows 11 x64, with two caveats:

  • I think there was some ESM/CJS interop stuff that I was missing in the tester code that wasn't a problem in Node 22. The code doesn't work for Node 20 and under.
  • Reading the original issue more carefully, I see the error log seems to point to a .webpack folder. Are you also using the Webpack plugin?

erickzhao avatar Jan 31 '25 17:01 erickzhao

Hey @bearsworth, thanks for the response. My tester code also compiled for me on Windows 11 x64, with two caveats:

  • I think there was some ESM/CJS interop stuff that I was missing in the tester code that wasn't a problem in Node 22. The code doesn't work for Node 20 and under.
  • Reading the original issue more carefully, I see the error log seems to point to a .webpack folder. Are you also using the Webpack plugin?

It's been some time since I've viewed it so I don't quite remember the details. I think there was some type of webpack to bundle it, but I do also believe it has to do with some esm/cjs thing which you mentioned.

bearsworth avatar Feb 03 '25 00:02 bearsworth