Sharp: Sharp inside Electron

Created on 12 Mar 2019  路  4Comments  路  Source: lovell/sharp

Hello, I need to have shap running inside Electron app (which runs React app, but that should not affect it).

I get this error when I try to install using yarn:

App threw an error during load
Error: The module '\\?\C:\Development\Electron\FileCtor\node_modules\sharp\build\Release\sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. Please try re-compiling or re-installing

So I tried to use the electron-rebuild, but then I get this error:

App threw an error during load
Error: \\?\C:\Development\Electron\FileCtor\node_modules\sharp\build\Release\sharp.node is not a valid Win32 application.
\\?\C:\Development\Electron\FileCtor\node_modules\sharp\build\Release\sharp.node
     at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
     at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
     at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
     at Module.load (internal/modules/cjs/loader.js:602:32)
     at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
     at Function.Module._load (internal/modules/cjs/loader.js:533:3)
     at Module.require (internal/modules/cjs/loader.js:640:17)
     at require (internal/modules/cjs/helpers.js:20:18)
     at bindings (C:\Development\Electron\FileCtor\node_modules\bindings\bindings.js:112:48)
     at Object.<anonymous> (C:\Development\Electron\FileCtor\node_modules\sharp\lib\constructor.js:10:34)

After this I tried to uninstall node and then install the same version as Electron uses, but this did not help either. I'm fairly inexperienced when it comes to node native modules, so I'm not sure what can else I can try to do to solve this. I'm sure I was able to get different native module running previously using node-gyp.

I am using Windows 10 64bit, Electron is 4.0.8. Node is currently 10.11.0 same as Electron should be using.

question

Most helpful comment

The binaries for the next sharp release will pick up changes from the various upstream dependencies and should therefore work with Electron v4.0.4+. (This problem affected all native modules, not just sharp, and was due to Electron breaking its own ABI.)

I'll update #1522 when all this happens so please subscribe to it.

All 4 comments

Hello, for Electron 4 pain please see #1522 - you'll probably need to use Electron 3 for now.

Thanks, I have read it and also some other issues posted elsewhere and unfortunately it seems you are right. None of the suggestions seems to work for me and I dislike going back to older Electron, but solving this issue this seems to be out your hands? Should I wait for Electron update?

I don't understand it properly, but some link here, that this should solve the issue? https://github.com/electron/electron/pull/16687

The binaries for the next sharp release will pick up changes from the various upstream dependencies and should therefore work with Electron v4.0.4+. (This problem affected all native modules, not just sharp, and was due to Electron breaking its own ABI.)

I'll update #1522 when all this happens so please subscribe to it.

@lovell

Electron 4.1.0 seems to have solved this issue,Is it?

Electron 4.1.0 was released to work around issues users were experiencing with node-pre-gyp based native modules and our ABI number in Electron >= 4.0.4.

https://electronjs.org/releases/stable#4.1.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emmtte picture emmtte  路  3Comments

Andresmag picture Andresmag  路  3Comments

zhump picture zhump  路  3Comments

iq-dot picture iq-dot  路  3Comments

terbooter picture terbooter  路  3Comments