The specified module could not be found, with electron v4.0.0.
With electron 3.0.12 everything seems to work fine.
Changed version to 4.0.0, removed node_modules, did npm i, all ok.
If I run electron-rebuild, the command runs, but it does not rebuild the sharp module, does not seem it's picking it up.
If I run require('sharp') I get:
The specified module could not be found
If I cd to node_modules/sharp and try to recompile it manually:
node-gyp rebuild --target=4.0.0 --arch=x64 --dist-url=https://atom.io/download/electron
and try require('sharp') I still get The specified module could not be found.
Note: I have checked and sharp.node is present at the specified path.
The target flag passed to node-gyp refers to the version of Node rather than the version of Electron.
You'll probably want to use electron-rebuild.
electron-rebuild is what I am currently using with Electron 3, but it fails with Electron 4.
And by fail I mean it does nothing, it just skips the sharp package, that's why I tried manually with node-gyp.
From what I understand the version is for electron since dist-url is set to https://atom.io/download/electron
Is this on Windows? If so, try pointing Dependency Walker at the sharp.node file to help determine which shared library might be causing the problem.
sharp.zip I have the same issue and here is my Dependency Walker file.
Thanks, according to that .dwi file the missing shared library is node.dll so I guess either something changed in the way Electron 4 provides/packages this and/or electron-rebuild does not yet support it.
I'd imagine other native modules are going to fail in a similar manner - ~please can you report this downstream~.
"However, in Electron 4.x and higher, the symbols needed by native modules are exported by electron.exe, and there is no node.dll in Electron 4.x."
https://electronjs.org/docs/tutorial/using-native-node-modules#troubleshooting
Thank you, but I still don't understand how to make things right, or maybe I should just wait for electron-rebuild to release some update?
Please can someone confirm that this problem is limited to Windows only. Is anyone able to produce a minimal repo that exhibits the problem?
I have placed a very simple repo which exhibits the problem here https://github.com/groboter/sharpErrorTestApp. I hope it is ok, because it is my first one!
Basically it is just the Quick-Start-App from https://github.com/electron/electron-quick-start and I just added line 3 const {sharp} = require('sharp') which produces the error.
The version of Node in Electron 3 does not appear to maintain ABI compatibility with the version in Electron 4 despite both claiming to provide ABI version 64.
When you run electron-rebuild it calls prebuild-install, which correctly reports that it has a prebuilt binary for Electron with Node ABI version 64. However this binary fails with Electron 4 due to a change in Node ABI without a corresponding version increment.
You can hack your way around this by removing prebuild-install before running electron-rebuild.
npm install
rm -rf node_modules/prebuild-install
./node_modules/.bin/electron-rebuild
In summary, Electron needs to sort out its ABI versioning.
Here's confirmation of the Electron 3 vs 4 ABI incompatibility - https://github.com/lgeiger/node-abi/pull/55#issuecomment-452588421 - this will impact all native modules that provide prebuilt binaries for Electron.
@lovell Thank you for clarification and for such an awesome library in general.
https://github.com/electron/electron/pull/16687 Am I correct that this should fix the issue? But I am still getting an error when building with electron-builder on mac.
pp threw an error during load Error: The module '//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 the module (for instance, using
npm rebuildornpm install). 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 (//node_modules/sharp/node_modules/bindings/bindings.js:112:48) at Object.(/*/node_modules/sharp/lib/constructor.js:10:34)
This is probably an electron-builder issue and not a sharp one.
@midevnull https://github.com/electron-userland/electron-builder/issues/3660
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.
Fixed a crash when calling ECDH.setPrivateKey(). #17297 TouchBarSegmentedControl instances now correctly update when you update the segments array and remove label or image dynamically. #17335 https://electronjs.org/releases/stable#4.1.0
I tried just Electron v4.1.0, but in my case it did not help. Gonna have to wait for sharp update.
I tried just Electron v4.1.0, but in my case it did not help. Gonna have to wait for sharp update.
@tomaschyly: Did you clean your build machine? I had to not only delete my project's node_modules, but
rm -rf ~/.electron ~/.electron-gyp ~/.npm/_libvips* ~/.node-gyp ~/.cache/yarn/*/*sharp*
(I added it as postinstall script)
Yes I did try to clean everything, but it seems that I will have to wait for update like I have been told here https://github.com/lovell/sharp/issues/1608
The ABI version of 69 used by Electron 4 is (correctly) considered "oddball" by the prebuild infrastructure so this is still blocked until the approach proposed in https://github.com/prebuild/prebuild-ci/issues/11 is addressed.
What is the workaround for this? Using Electron 3?