forge icon indicating copy to clipboard operation
forge copied to clipboard

Cannot find module 'undefinedbuild/Release/sharp-win32-x64.node'

Open ghost opened this issue 3 years ago • 4 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

6.0.4

Electron version

22.0.0

Operating system

Windows 10

Last known working Electron Forge version

No response

Expected behavior

Should be able to use the venom-bot methods, venom-bot uses sharp and then run and package the app

Actual behavior

After adding the venom-bot package when I call the venom-package methods it throws following error:


App threw an error during load
Error: 
Something went wrong installing the "sharp" module

Cannot find module 'undefinedbuild/Release/sharp-win32-x64.node'
Require stack:
- C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js
- C:\Users\admin\Desktop\forge-sharp-example\node_modules\electron\dist\resources\default_app.asar\main.js
-

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current win32-x64 runtime: "npm install --platform=win32 --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at ./node_modules/sharp/lib/sharp.js (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:42357:9)
    at __webpack_require__ (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:85802:42)
    at ./node_modules/sharp/lib/constructor.js (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:38511:1)
    at __webpack_require__ (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:85802:42)
    at ./node_modules/sharp/lib/index.js (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:38903:15)
    at __webpack_require__ (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:85    at __webpack_require__ (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:85802:42)
    at ./node_modules/venom-bot/dist/api/helpers/index.js (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:49577:24)
    at __webpack_require__ (C:\Users\admin\Desktop\forge-sharp-example\.webpack\main\index.js:85802:42)

Steps to reproduce

I have added a sample repo:

Visit https://github.com/piedpie/forge-sharp-example Clone the repo and run

npm install

npm start

Additional information

I already tried following:

  • Install with verbose logging and look for errors: npm install --ignore-scripts=false --foreground-scripts --verbose sharp

  • Install for the current win32-x64 runtime: npm install --platform=win32 --arch=x64 sharp

  • Aso deleted node_modules and tried npm install sharp --ignore-scripts false

ghost avatar Dec 24 '22 13:12 ghost

This sounds like an issue with renderer sandboxing in Electron 22, which is where the undefined in that path is coming from. You can get past that with sandbox: false in your BrowserWindow.

As an aside, there's a separate issue with certain native modules like Sharp which might require you to stick to Electron 20 for now: https://github.com/electron/electron/issues/35801

erickzhao avatar Jan 03 '23 20:01 erickzhao

related to https://github.com/vercel/webpack-asset-relocator-loader/issues/161

and https://github.com/electron/forge/issues/3258

sibelius avatar Aug 29 '23 18:08 sibelius

I am having this issue also windows 10? any luck?

Deestar avatar Sep 18 '23 09:09 Deestar

I’m experiencing the same issue with sqlite3:

App threw an error during load
Error: Cannot find module 'undefinedbuild/Release/node_sqlite3.node'

As far as I understand, in my case the problem is related to the bundled /main/index.js file.

In .webpack/main.js:

// Works because the file exists there
module.exports = require("./native_modules/build/Release/node_sqlite3.node");

// Original bundle code
module.exports = require(__webpack_require__.ab + "build/Release/node_sqlite3.node");

It seems that __webpack_require__.ab is undefined. Sometimes, the original bundle code works. In those cases, I can find the source of ab. But for an unknown reason, that code is sometimes missing in the output bundle:

/************************************************************************/
/******/ 	/* webpack/runtime/asset-relocator-loader */
/******/ 	if (typeof __webpack_require__ !== 'undefined') {
                 __webpack_require__.ab = __dirname + "/native_modules/";
            }
/******/

sajera avatar Aug 13 '25 11:08 sajera