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.

Sharp w/ Electron not loading (electron-forge)

See original GitHub issue

Problem: I’m trying to use sharp w/ electron. Everything (sharp+electron) is working in OSX. On Windows (using gitbash), I’m able to use sharp globally installed with a simple node.js test, but not in electron. As soon as I uncomment const sharp = require('sharp'); the app white-screens and doesn’t load (no further errors / hints / direction).

Install Sharp installs w/o errors: verbose output from fresh install: link non-verbose:

$ npm i --save sharp

sharp@0.23.2 install C:\Users\andrew\code\js\electron\spec-electron\node_modules\sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-win32-x64.tar.gz info sharp Creating C:\Users\andrew\code\js\electron\spec-electron\node_modules\sharp\build\Release info sharp Copying DLLs from C:\Users\andrew\code\js\electron\spec-electron\node_modules\sharp\vendor\lib to C:\Users\andrew\code\js\electron\spec-electron\node_modules\sharp\build\Release

  • sharp@0.23.2 added 13 packages from 65 contributors and audited 14365 packages in 21.978s found 20 vulnerabilities (5 low, 8 moderate, 6 high, 1 critical) run npm audit fix to fix them, or npm audit for details

Environment:

$ npx envinfo --binaries --languages --system – utilities npx: installed 1 in 1.828s

System: OS: Windows 10 CPU: (2) x64 Intel® Core™ i7-6820HQ CPU @ 2.70GHz Memory: 3.40 GB / 7.10 GB Binaries: Node: 12.4.0 - C:\Program Files\nodejs\node.EXE npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Languages: Bash: 4.4.23 - C:\Program Files\Git\usr\bin\bash.EXE Perl: 5.26.2 - C:\Program Files\Git\usr\bin\perl.EXE Python: 2.7.17 - C:\Python27\python.EXE

Similar question:

This is very similar to #1846, but the suggested solutions aren’t working:

Attempting solution from @lovell :

andrew@ANDREWT0C72 MINGW64 ~/code/js/electron/spec-electron (windows10) $ ./node_modules/.bin/electron-rebuild

  • Searching dependency tree √ Rebuild Complete

but problem persists

Attempting solution from Mubaidr:

$ ./node_modules/.bin/electron-builder install-app-deps • electron-builder version=22.1.0 • rebuilding native dependencies dependencies=@serialport/bindings@8.0.4, sharp@0.23.2 platform=win32 arch=x64 • install prebuilt binary name=@serialport/bindings version=8.0.4 platform=win32 arch=x64 • build native dependency from sources name=@serialport/bindings version=8.0.4 platform=win32 arch=x64 reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information) error=prebuild-install info begin Prebuild-install version 5.3.3 prebuild-install WARN install prebuilt binaries enforced with --force! prebuild-install WARN install prebuilt binaries may be out of date! prebuild-install info looking for cached prebuild @ C:\Users\andrew\AppData\Roaming\npm-cache_prebuilds\afca11-bindings-v8.0.4-electron-v73-win32-x64.tar.gz prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/v8.0.4/bindings-v8.0.4-electron-v73-win32-x64.tar.gz prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/v8.0.4/bindings-v8.0.4-electron-v73-win32-x64.tar.gz prebuild-install WARN install No prebuilt binaries found (target=6.1.4 runtime=electron arch=x64 libc= platform=win32)

• install prebuilt binary name=sharp version=0.23.2 platform=win32 arch=x64

despite error on prebuild install for serialport - serial port still ends up working, uncommenting sharp still causes the app to fail to load.

I’m getting no errors out in the main console, nor in chrome tools console - so I’m grabbing at straws / looking for any ideas on what else I can try.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
emmekappacommented, Aug 21, 2020

@andrewrt any update on this? I’m facing the same issue

0reactions
pkerschbaumcommented, Jan 3, 2022

@Cosmin-Parvulescu This electron-forge project I am working on is only meant to run on Windows and Linux (and Mac OS eventually). So far, I tested the packaged application on both Windows x64 and WSL 2 Ubuntu (WSLg), and I can confirm that my approach - copying sharp and its dependencies manually - does work on these platforms.

But I don’t know if it would work on Android.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error recompiling "sharp" for electron - node.js - Stack Overflow
I am trying to run electron-rebuild sharp so that I can use the sharp package in electron. ... If I run the command...
Read more >
Developing with WSL - Electron Forge
Simply trying to run an Electron app in development that you've installed dependencies in WSL will try and fail to find an X11...
Read more >
How to make your Electron app faster - DEV Community ‍ ‍
So you just made a nice & shiny new app with Electron. ... Use faster JavaScript methods, especially when working with DOM ......
Read more >
Things I Wish I Knew Before Working with Electron.js
js ?‍♂️. I hope it helps! Note: This wont be a coding tutorial, but rather a discussion about my personal takeaways. A couple ......
Read more >
Getting Started With Electron JS With Visual Studio Code
As of now, in this article, it was changed to "app" and change the directory to app. It is not compulsory. We will...
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