-
-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electron-forge (5.x & 6.x)+Sharp crashing w/o much debug hints #1276
Comments
Issue logged w/ the sharp author - assumed electron-forge v6 might fix, to no avail (lovell/sharp#1951) |
as noted in lovell/sharp#1951 - got it working. |
A quick heads up - the above gets it working in dev mode, but when packaging - the sharp module gets left out in the packaged app. Trying to figure out how @shadeofgod 's if I add the copy plugin to my const rules = require('./webpack.rules');
const CopyPlugin = require('copy-webpack-plugin');
rules.push({
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
});
module.exports = {
// Put your normal webpack config below here
module: {
rules ,
},
externals: {
"sharp": 'commonjs sharp',
},
plugins: [
new CopyPlugin([
{
from: './node_modules/sharp/',
to: './output/node_modules/sharp/', // still under node_modules directory so it could find this module
// ignore: [...]
},
]),
]
}; output from the console:
|
I am facing the same problem. Woudl be great if anyone had an idea on how to fix this. |
@mauricedoepke any updates on this? I am facing the same issue... |
@aperkaz 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 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. |
@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 🙂 |
For this reason I've created this plugin that helps include native modules during packaging. You pass it a list of modules and it searches for all dependencies and includes them in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Duplicate of #1250 |
TLDR:
electron-forge@5.2.4
+sharp
image module work well in OSX.sharp image module stand-alone works in Windows 10 (
git-bash
), butconst 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
andnode-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 variableDEBUG=electron-forge:*
. (Instructions on how to do so here). Please include the stack trace if one exists.What command line arguments are you passing?
What does your
config.forge
data inpackage.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 thesource of your problem.
Simple project to reproduce:
https://github.com/andrewrt/ef6-sharp/blob/master/src/app.js
The text was updated successfully, but these errors were encountered: