Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Not working with sharp again "Cannot include directory %1 into executable." #1918

Closed
rightaway opened this issue Apr 20, 2023 · 7 comments
Closed
Labels

Comments

@rightaway
Copy link

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

> pkg@5.7.0
compression:  GZip
> Warning Cannot include directory %1 into executable.
  The directory must be distributed with executable as %2.
  %1: node_modules/sharp/build/Release
  %2: path-to-executable/sharp/build/Release
> Warning Cannot include directory %1 into executable.
  The directory must be distributed with executable as %2.
  %1: node_modules/sharp/vendor/lib
  %2: path-to-executable/sharp/vendor/lib

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.

"assets": [
  "node_modules/sharp/build/Release",
  "node_modules/sharp/vendor/lib"
]
"assets": [
  "node_modules/sharp/build/Release/sharp-linux-x64.node"
]

According to #1075 sharp should be working but it's not.

#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.

@robertsLando
Copy link
Contributor

Try to use "node_modules/sharp/**" as asset. Also even if you see that warning it doesn't mean the binary will not work

@hjyssg
Copy link

hjyssg commented May 20, 2023

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.
image

@sbochkar
Copy link

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

@baparham
Copy link
Contributor

baparham commented Jul 7, 2023

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?

@nononoyeah
Copy link

nononoyeah commented Aug 16, 2023

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。
image

image

Copy link

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

@github-actions github-actions bot added the Stale label Nov 15, 2023
Copy link

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants