question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aperkazcommented, Apr 11, 2021

@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 🙂

1reaction
mauricedoepkecommented, Apr 10, 2021

@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:

  • using jimp, apure js image manipulations lib which runs everywhere, but is painufully slow and runs out of memory for larger images.
  • using https://github.com/kleisauke/wasm-vips which currently works only in the browser context (uses experimental wasm features that are not yet available in the electron node context)
  • using https://github.com/silvia-odwyer/photon which is also wasm based and should run in browser and node (I did not try it with electron forge)

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:

"rebuild": "yarn add sharp && copyfiles sqlite3.tar.gz ./node_modules/better-sqlite3/deps && electron-rebuild -o better-sqlite3",

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron-forge (5.x & 6.x)+Sharp crashing w/o much debug ...
I have tried using electron-rebuild and node-gyp to force rebuild sharp for electron, but that changed nothing. Both show that sharp was ...
Read more >
Debugging
Debugging your Electron main process through VS Code is ridiculously easy with Forge. Simply add this as a launch config in VSCode and...
Read more >
Tips on solving 'DevTools was disconnected from the page' ...
The trick to debugging a crash like this, is to enable logging, which is apparently disabled by default. This ...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/24 17 ...
Bug:128538 - "sys-apps/coreutils: /bin/hostname should be installed from coreutils not sys-apps/net-tools" status:UNCONFIRMED resolution: severity:enhancement ...
Read more >
qTh - River Thames Conditions - Environment Agency - GOV.UK
Sonic x episode 109, Enigma datapack final offer theater, Poodles mixes for ... Custom switchback harley, Song so hee la kpop festival, Partitur...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found