forge icon indicating copy to clipboard operation
forge copied to clipboard

Unable to load preload script with latest package @vercel/[email protected]

Open shiftonetothree opened this issue 6 months ago • 5 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.

Forge version

7.8.1

Electron version

v36.5.0

Operating system

Windows 11 企业版 LTSC

Last known working Forge version

7.8.1

Expected behavior

renderer with no error

Actual behavior

renderer with error in electron window dev tool, and window is blank

VM4 sandbox_bundle:2 Unable to load preload script: C:\Users\AI\Desktop\ai-learning-assistant-launcher\.webpack\renderer\main_window\preload.js
executeSandboxedPreloadScripts @ VM4 sandbox_bundle:2
VM4 sandbox_bundle:2 ReferenceError: __dirname is not defined
    at <anonymous>:389:84
    at <anonymous>:1412:12
    at runPreloadScript (VM4 sandbox_bundle:2:144346)
    at executeSandboxedPreloadScripts (VM4 sandbox_bundle:2:143619)
    at VM4 sandbox_bundle:2:154017
    at VM4 sandbox_bundle:2:154219
    at ___electron_webpack_init__ (VM4 sandbox_bundle:2:154223)
    at VM4 sandbox_bundle:2:154346
executeSandboxedPreloadScripts @ VM4 sandbox_bundle:2
index.js:33520 Uncaught ReferenceError: __dirname is not defined
    at index.js:33520:84
    at index.js:34614:12
VM4 sandbox_bundle:2 Electron Security Warning (Insecure Content-Security-Policy) This renderer process has either no Content Security
  Policy set or a policy with "unsafe-eval" enabled. This exposes users of
  this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.
warnAboutInsecureCSP @ VM4 sandbox_bundle:2

Image

Steps to reproduce

git clone https://github.com/ai-learning-assistant-dev/ai-learning-assistant-launcher.git
git checkout - b shiftonetothree_dev origin/shiftonetothree_dev
npm i
nom i @vercel/webpack-asset-relocator-loader@latest
npm run start

Additional information

No response

shiftonetothree avatar Jul 20 '25 00:07 shiftonetothree

I tried to upgrade from 1.7.0 to 1.10.0 and I now get the same error in my project. I have downgraded back to 1.7.0 for now.

viemmsakh avatar Jul 30 '25 14:07 viemmsakh

@viemmsakh yes, it's only work on not bigger than 1.7.3

shiftonetothree avatar Jul 31 '25 11:07 shiftonetothree

We specifically monkeypatch that package to work with Electron Forge. Is there a reason you want to install 1.10.0?

erickzhao avatar Jul 31 '25 18:07 erickzhao

We specifically monkeypatch that package to work with Electron Forge. Is there a reason you want to install 1.10.0?

npm auto upgrade my @vercel/webpack-asset-relocator-loader

shiftonetothree avatar Aug 09 '25 01:08 shiftonetothree

downgrade to 1.7.3 worked for me

sheltonsuen avatar Aug 18 '25 03:08 sheltonsuen