Closed marchrap closed 2 years ago
Hi, this is likely to be due to the same underlying problem as #2764, namely that the electron tooling doesn't quite yet support Node-API (previously known as N-API).
Hi, thanks for confirming that this most likely comes from #2764. I tried installing the version of electron-rebuild
with the pull request suggested by @timfish by running:
npm install --save-dev electron/electron-rebuild#pull/737/head
And then tried recompiling sharp
using:
.\node_modules\.bin\electron-rebuild.cmd
Now I obtain the following error (similar to what I found previously):
C:\Users\Altair\Desktop\gui\node_modules\sharp\lib\constructor.js:32 Uncaught Error:
Something went wrong installing the "sharp" module
A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\Altair\Desktop\gui\node_modules\sharp\build\Release\sharp.node
- Remove the "node_modules/sharp" directory then run
"npm install --ignore-scripts=false --verbose sharp" and look for errors
- Consult the installation documentation at https://sharp.pixelplumbing.com/install
- Search for this error at https://github.com/lovell/sharp/issues
at Object.<anonymous> (C:\Users\Altair\Desktop\gui\node_modules\sharp\lib\constructor.js:32)
at Object.<anonymous> (C:\Users\Altair\Desktop\gui\node_modules\sharp\lib\constructor.js:394)
at Module._compile (internal/modules/cjs/loader.js:711)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:722)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at Object.<anonymous> (C:\Users\Altair\Desktop\gui\node_modules\sharp\lib\index.js:3)
@timfish it is something I should expect?
sharp
relies on the correct additional libraries being copied via an install script.
Currently, electron-rebuild
does not run install scripts
@marchrap Can you avoid the use of electron-rebuild
entirely? It seems to cause more problems than it solves, and the prebuilt binaries provided by sharp should already "just work" with Electron.
Yes, I can avoid using it entirely. I only want to get sharp
working. I tried the following:
npm install --verbose --ignore-scripts=false sharp
Which resulted in:
Uncaught Error:
Something went wrong installing the "sharp" module
A dynamic link library (DLL) initialization routine failed. \?\C:\Users\Altair\Desktop\gui\node_modules\sharp\build\Release\sharp.node
Search for this error at https://github.com/lovell/sharp/issues
at Object.
2. Copying manually the binaries from the releases (`sharp-v0.28.3-napi-v3-win32-x64.tar.gz`) on GitHub which resulted in:
C:\Users\Altair\Desktop\gui\node_modules\sharp\lib\constructor.js:32 Uncaught Error: Something went wrong installing the "sharp" module
The specified module could not be found. \?\C:\Users\Altair\Desktop\gui\node_modules\sharp\build\Release\sharp.node
Search for this error at https://github.com/lovell/sharp/issues
at Object.
@lovell I'm not sure you had any of those methods in mind?
Please can you try using https://www.dependencywalker.com/ with C:\Users\Altair\Desktop\gui\node_modules\sharp\build\Release\sharp.node
and look for any errors.
If you're able to create a minimal, standalone repo that allows someone else to reproduce this, that would be very helpful.
I tried using dependency walker but it hangs (most likely due to this issue) so I tried Dependencies. It seems that all the modules are there apart from some api-ms-win
and ext-ms-win
ones (the ones available are truncated):
[NOT_FOUND] api-ms-win-core-comm-l1-1-0.dll :
[NOT_FOUND] api-ms-win-core-xstate-l2-1-0.dll :
[NOT_FOUND] api-ms-win-core-xstate-l2-1-1.dll :
[NOT_FOUND] ext-ms-win-oobe-query-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-shell32-shellcom-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-security-chambers-l1-1-0.dll :
[NOT_FOUND] ext-ms-win32-subsystem-query-l1-1-0.dll :
[NOT_FOUND] api-ms-win-core-stringansi-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-dx-d3dkmt-dxcore-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-core-winrt-remote-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-com-apartmentrestriction-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-com-suspendresiliency-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-ro-typeresolution-l1-1-0.dll :
[NOT_FOUND] api-ms-win-core-com-private-l1-3-0.dll :
[NOT_FOUND] ext-ms-win-ntuser-window-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-ntuser-window-l1-1-3.dll :
[NOT_FOUND] ext-ms-win-ntuser-window-l1-1-4.dll :
[NOT_FOUND] ext-ms-win-ntuser-window-l1-1-1.dll :
[NOT_FOUND] ext-ms-win-shell-shell32-l1-2-0.dll :
[NOT_FOUND] ext-ms-win-ntuser-window-l1-1-2.dll :
[NOT_FOUND] api-ms-win-security-sddlparsecond-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-smbshare-browserclient-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-appmodel-deployment-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-appmodel-usercontext-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-ui-viewmanagement-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-shell32-shellfolders-l1-1-0.dll :
[NOT_FOUND] ext-ms-windowscore-deviceinfo-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-containers-policymanagercli-l1-1-0.dll :
[NOT_FOUND] api-ms-win-core-versionansi-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-appmodel-viewscalefactor-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-shell-knownfolderext-l1-1-0.dll :
[NOT_FOUND] ext-ms-onecore-defaultdiscovery-l1-1-0.dll :
[NOT_FOUND] HvsiFileTrust.dll :
[NOT_FOUND] UpdateAPI.dll :
[NOT_FOUND] ext-ms-win-shell-shlwapi-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-rtcore-minuser-private-ext-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-dwmapi-ext-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-rtcore-minuser-input-l1-1-1.dll :
[NOT_FOUND] ext-ms-mf-pal-l2-1-0.dll :
[NOT_FOUND] api-ms-win-coreui-secruntime-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-dxcore-internal-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-dx-d3dkmt-gdi-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-core-app-package-registration-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-audiocore-pal-l1-2-0.dll :
[NOT_FOUND] ext-ms-win-audiocore-spatial-l1-1-0.dll :
[NOT_FOUND] api-ms-win-core-versionansi-l1-1-1.dll :
[NOT_FOUND] api-ms-win-core-version-private-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-rtcore-minuser-private-ext-l1-1-1.dll :
[NOT_FOUND] ext-ms-onecore-orientation-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-rtcore-minuser-internal-l1-1-0.dll :
[NOT_FOUND] ext-ms-onecore-shellchromeapi-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-ras-tapi32-l1-1-1.dll :
[NOT_FOUND] ext-ms-win-networking-wlanstorage-l1-1-0.dll :
[NOT_FOUND] ext-ms-win-wer-xbox-l1-1-0.dll :
However, I think this does not matter.
While preparing the repo for you I made it work by accident. I achieved this by running:
npm install lovell\sharp
and then,npm run postinstall
where for me postinstall
is electron-builder install-app-deps
(which I think is equivalent to executing npx electron-builder install-app-deps
) Interestingly, running npm install sharp
and then the second command, does not work. Neither does just copying manually the binaries from the releases (sharp-v0.28.3-napi-v3-win32-x64.tar.gz
) on GitHub.
Presumably, installing directly from GitHub works because of the commits which were made between now and the last release. But if you think this is not the case, I can provide you with a test repo. Otherwise, this can be closed now. Thanks for all the help!
Closing in favour of #2764 to track the (historic?) problem of using electron-rebuild.
Overall description I am running an Electron application. After installing the sharp module, and running the application I obtained the following warning:
I thought it might be related to the native modules so I run
.\node_modules\.bin\electron-rebuild.cmd
. The error then changes to:During installation I obtained the following information (which might be adding some insight):
This might be related to the following issues (where I have not found a solution to this problem) #2764, #2030 . I run the same application on Linux and I have seen a similar error (
Something went wrong installing the "sharp" module
) but after rerunning the application it disappeared.Thank you for any help! Sharp is my first native module so my experience is quite limited and I might be doing wrong something relatively simple.
Did you see the documentation relating to installation? Yes.
Have you ensured the architecture and platform of Node.js used for
npm install
is the same as the architecture and platform of Node.js used at runtime? Yes.Are you using the latest version? Is the version currently in use as reported by
npm ls sharp
the same as the latest version as reported bynpm view sharp dist-tags.latest
? Yes. Both return 0.28.3.If you are using npm v6 or earlier and installing as a
root
orsudo
user, have you tried with thenpm install --unsafe-perm
flag? Yes (when tested with npm v6).If you are using npm v7, does the user running
npm install
own the directory it is run in? Yes (when tested with npm v7).If you are using the
ignore-scripts
feature ofnpm
, have you tried with thenpm install --ignore-scripts=false
flag? Yes.What is the complete output of running
npm install --verbose sharp
? Have you checked this output for useful error messages? Yes.What is the output of running
npx envinfo --binaries --system
?Thanks again for any help!