Closed rightaway closed 1 year ago
Try to use "node_modules/sharp/**"
as asset. Also even if you see that warning it doesn't mean the binary will not work
I used the solution provided above, didnt work. I hope pkg team could just provide some kind of example project for this issue. Since so many issue about sharp and sqlite.
Also facing this issue.
Adding "node_modules/sharp/**" to asset seems to work when compiling for the linux platform. This is the platform where my development happens.
However, it does not help with cross compiling for win platform.
Below is what I get when I try to run exe on Windows platform.
PS C:\.......
pkg/prelude/bootstrap.js:1872
throw error;
^
Error:
Something went wrong installing the "sharp" module
The specified module could not be found.
C:\...\AppData\Local\Temp\pkg\028b5dfb4c795afee359660beef08cc4cf2733dc7f19bfeafc7a8365c82adb97\sharp\build\Release\sharp-win32-x64.node
Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current win32-x64 runtime: "npm install --platform=win32 --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
at Object.<anonymous> (C:\snapshot\project-name\node_modules\sharp\lib\sharp.js:37:9)
at Module._compile (pkg/prelude/bootstrap.js:1926:22)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:834:12)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at Module.require (pkg/prelude/bootstrap.js:1851:31)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\snapshot\project-name\node_modules\sharp\lib\constructor.js:11:1)
at Module._compile (pkg/prelude/bootstrap.js:1926:22)
Node.js v18.5.0
Checking the AppData folder shows that the files ARE in that folder.
PS > ls C:\...\AppData\Local\Temp\pkg\028b5dfb4c795afee359660beef08cc4cf2733dc7f19bfeafc7a8365c82adb97\sharp\build\Release\
Directory: C:\...\AppData\Local\Temp\pkg\028b5dfb4c795afee359660beef08cc4cf2733dc7f19bfeafc7a8365c82adb97\sharp\build\Release
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2023-05-26 1:51 PM 369664 libvips-cpp.dll
-a---- 2023-05-26 1:51 PM 248224 sharp-linux-x64.node
-a---- 2023-05-26 1:51 PM 248224 sharp-linux-x64.node.win.v18.5.0
-a---- 2023-05-26 1:51 PM 406016 sharp-win32-x64.node
-a---- 2023-05-26 1:51 PM 406016 sharp-win32-x64.node.win.v18.5.0
did you try reinstalling sharp for windows before you compiled your pkg binary? E.g.
npm install --platform=win32 --arch=x64 sharp
as the error message suggests.
Sharp uses native .node files that are compiled and platform specific, so you are trying to run a linux compiled native node module on a windows machine.
Do you have the ability to build your windows pkg distributable on windows itself natively?
I had the same problem,When I change sharp version to 0.29.3 and add "node_modules/sharp/*/*." to pkg assets, then it works。
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.
What version of pkg are you using?
5.7.0
What version of Node.js are you using?
16.15.0
What operating system are you using?
linux
What CPU architecture are you using?
amd64
What Node versions, OSs and CPU architectures are you building for?
node16-linux-64
Describe the Bug
When I run pkg there are warnings
To Reproduce
Try running pkg with sharp as a dependency. You can add these to package.json which I thought would fix it but it didn't.
According to https://github.com/vercel/pkg/issues/1075 sharp should be working but it's not.
https://github.com/vercel/pkg/issues/229 is a similar issue but like many issues in this vercel pkg repository it got closed automatically even though it's still not working.