electron-forge (5.x & 6.x)+Sharp crashing w/o much debug hints
See original GitHub issue- [X ] I have read the contribution documentation for this project.
- [ X] I agree to follow the code of conduct that this project follows, as appropriate.
- [ X] I have searched the issue tracker for an issue that matches the one I want to file, without success.
TLDR:
electron-forge@5.2.4
+ sharp
image module work well in OSX.
sharp image module stand-alone works in Windows 10 (git-bash
), but
const sharp = require('sharp')
causes the app (renderer) to not load / just show white).
For electron-forge@6.0.0-beta.45
:
In electron-forge 6.x when running, I get an error now - but it doesn’t give enough info for me to be able to debug further (see below) the error doesn’t tell me what is doing the “syscall” / “read” so I’m hoping someone might have some further ideas on how to get more info on the failed import/require.
Native Module Rebuild Attempts:
I have tried using electron-rebuild
and node-gyp
to force rebuild sharp for electron, but that changed nothing. Both show that sharp was successfully added / rebuilt.
Using node-gyp to install:
https://gist.github.com/andrewrt/fa3a08f7346ef2c023565ed07c1fecd7
Here’s a simple repo to reproduce the problem: https://github.com/andrewrt/ef6-sharp
Console output when you run electron-forge
with the environment variable DEBUG=electron-forge:*
. (Instructions on how to do so here). Please include the stack trace if one exists.
andrew@ANDREWT0C72 MINGW64 ~/code/js/electron/test-ef6 (master)
$ electron-forge --verbose start
WARNING: DEBUG environment variable detected. Progress indicators will be sent over electron-forge:lifecycle
2019-11-07T23:38:37.387Z electron-forge:async-ora Process Started: Checking your system
2019-11-07T23:38:37.391Z electron-forge:check-system checking system, create ~/.skip-forge-system-check to stop doing this
2019-11-07T23:38:38.507Z electron-forge:async-ora Process Succeeded: Checking your system -- after 1.1s
WARNING: DEBUG environment variable detected. Progress indicators will be sent over electron-forge:lifecycle
2019-11-07T23:38:40.100Z electron-forge:async-ora Process Started: Locating Application
2019-11-07T23:38:40.100Z electron-forge:project-resolver searching for project in: C:\Users\andrew\code\js\electron\test-ef6
2019-11-07T23:38:40.103Z electron-forge:project-resolver electron-forge compatible package.json found in C:\Users\andrew\code\js\electron\test-ef6\package.json
2019-11-07T23:38:40.107Z electron-forge:async-ora Process Succeeded: Locating Application -- after 3ms
2019-11-07T23:38:40.111Z electron-forge:require-search searching [ '@electron-forge/plugin-webpack',
'C:\\Users\\andrew\\code\\js\\electron\\test-ef6\\@electron-forge\\plugin-webpack',
'C:\\Users\\andrew\\code\\js\\electron\\test-ef6\\node_modules\\@electron-forge\\plugin-webpack' ] relative to C:\Users\andrew\code\js\electron\test-ef6
2019-11-07T23:38:40.115Z electron-forge:require-search testing @electron-forge/plugin-webpack
2019-11-07T23:38:40.115Z electron-forge:require-search testing C:\Users\andrew\code\js\electron\test-ef6\@electron-forge\plugin-webpack
2019-11-07T23:38:40.119Z electron-forge:require-search testing C:\Users\andrew\code\js\electron\test-ef6\node_modules\@electron-forge\plugin-webpack
WARNING: DEBUG environment variable detected. Progress indicators will be sent over electron-forge:lifecycle
2019-11-07T23:38:41.568Z electron-forge:plugin:webpack hooking process events
2019-11-07T23:38:41.568Z electron-forge:async-ora Process Started: Preparing native dependencies
2019-11-07T23:38:43.795Z electron-forge:async-ora Process Renamed: Preparing native dependencies --> Preparing native dependencies: 0 / 1
2019-11-07T23:38:43.795Z electron-forge:async-ora Process Renamed: Preparing native dependencies: 0 / 1 --> Preparing native dependencies: 1 / 1
2019-11-07T23:38:43.799Z electron-forge:async-ora Process Succeeded: Preparing native dependencies: 1 / 1 -- after 2.2s
2019-11-07T23:38:43.799Z electron-forge:plugins plugin: "webpack" has taken control of the start command
2019-11-07T23:38:43.807Z electron-forge:async-ora Process Started: Compiling Main Process Code
2019-11-07T23:38:45.539Z electron-forge:async-ora Process Succeeded: Compiling Main Process Code -- after 1.7s
2019-11-07T23:38:45.539Z electron-forge:async-ora Process Started: Launch Dev Servers
2019-11-07T23:38:45.615Z electron-forge:async-ora Process Succeeded: Launch Dev Servers -- after 76ms
2019-11-07T23:38:45.615Z electron-forge:async-ora Process Started: Compiling Preload Scripts
2019-11-07T23:38:45.615Z electron-forge:async-ora Process Succeeded: Compiling Preload Scripts -- after 0ms
2019-11-07T23:38:45.627Z electron-forge:async-ora Process Started: Launching Application
2019-11-07T23:38:45.723Z electron-forge:async-ora Process Succeeded: Launching Application -- after 96ms
Webpack Output Available: http://localhost:9000
2019-11-07T23:38:45.723Z electron-forge:plugin:webpack hooking electron process exit
An unhandled rejection has occurred inside Forge:
{ [Error: EISDIR: illegal operation on a directory, read] errno: -4068, code: 'EISDIR', syscall: 'read' }
Electron Forge was terminated. Location:
{}
2019-11-07T23:38:48.855Z electron-forge:plugin:webpack handling process exit with: { cleanup: true }
2019-11-07T23:38:48.855Z electron-forge:plugin:webpack cleaning webpack watcher
2019-11-07T23:38:48.855Z electron-forge:plugin:webpack cleaning http server
2019-11-07T23:38:48.859Z electron-forge:plugin:webpack stopping logger
What command line arguments are you passing?
`DEBUG` and `--verbose`
What does your config.forge
data in package.json
look like?
see repo for package/config and reproducing the issue - https://github.com/andrewrt/ef6-sharp/blob/master/src/app.js
Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-forge init
is a good starting point, if that is not the
source of your problem.
Simple project to reproduce: https://github.com/andrewrt/ef6-sharp/blob/master/src/app.js
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (3 by maintainers)
Top GitHub Comments
@mauricedoepke I managed to get it to work (on the main process), by using babel and modifying the webpack configs.
Repo with working example: https://github.com/aperkaz/electron-forge-sharp
I could not make it work from a render process, so any PR is welcome 🙂
@aperkaz Even after lots of research and fiddling with the webpack config I was not able to make sharp work with electron-forge.
Some alternative solutions are:
But as even the wasm solutions are much slower then sharp (https://libvips.github.io/libvips/2020/09/01/libvips-for-webassembly.html) I switched to https://www.electron.build/ instead With electron build I was able to get sharp working. If you use other native modules then sharp, you need to make sure though, to exclude sharp js from being rebuild by electron-rebuild. This will mess up sharp and you have to reinstall it.
For this reason I have this script in my package.json:
Here I install a fresh version of sharp to fix possible corruptions of the installation and then only rebuild sqlite with electron rebuild to not corrupt sharp again.
This is a bit hacky, but works.
If you have detail questions, just write me via my email in my profile.