Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load the "sharp" module using the win32-x64 runtime #2975

Closed
meyvan opened this issue Jul 27, 2024 · 15 comments
Closed

Could not load the "sharp" module using the win32-x64 runtime #2975

meyvan opened this issue Jul 27, 2024 · 15 comments
Assignees
Labels
P2: important Critical issue which does not affect majority of users status: research needed 🔍 More in-depth research need to make a decision+ type: bug 🐛 Something isn't working @vendure/asset-server-plugin @vendure/core

Comments

@meyvan
Copy link

meyvan commented Jul 27, 2024

Describe the bug
When I try to create a new installation by following https://docs.vendure.io/guides/getting-started/installation/ guide I get the followinf error:

Error: Could not load the "sharp" module using the win32-x64 runtime
[worker] Possible solutions:
[worker] - Ensure optional dependencies can be installed:
[worker]     npm install --include=optional sharp
[worker]     yarn add sharp --ignore-engines
[worker] - Ensure your package manager supports multi-platform installation:
[worker]     See https://sharp.pixelplumbing.com/install#cross-platform
[worker] - Add platform-specific dependencies:
[worker]     npm install --os=win32 --cpu=x64 sharp
[worker] - Consult the installation documentation:

To Reproduce
Steps to reproduce the behavior:

  1. Use Windows 10/11
  2. Follow guide https://docs.vendure.io/guides/getting-started/installation/
  3. Run npm run dev
  4. See error

Expected behavior
Should run smoothly

Environment (please complete the following information):

  • @vendure/core version: v3.0.0
  • Nodejs version : v18.19.1
  • Database (mysql/postgres etc): postgres

Additional context

Sharp is only required if someone is using this strategy: https://docs.vendure.io/reference/core-plugins/asset-server-plugin/sharp-asset-preview-strategy

Why install it in the first place ? If someone wants to use it, let them install and use the strategy

Proposed Solution: Remove Sharp library as default and update docs to reflect the same

@meyvan meyvan added the type: bug 🐛 Something isn't working label Jul 27, 2024
@VitoorFranca
Copy link

Install sharp if you are using asset server strategy:

npm install --include=optional sharp
or
yarn add sharp --ignore-engines

@meyvan
Copy link
Author

meyvan commented Jul 27, 2024

Install sharp if you are using asset server strategy:

npm install --include=optional sharp or yarn add sharp --ignore-engines

Mate two things:

  1. Even if I run the above it's still the same issue
  2. I'm not using the SharpAssetPreviewStrategy, im using the S3AssetStorageStrategy

My question is why is included as part of core packages ? Since the entire architecture is strategy based why not let the end user install it IF AND ONLY IF they use SharpAssetPreviewStrategy ?

@ziban
Copy link

ziban commented Jul 29, 2024

Install sharp if you are using asset server strategy:

npm install --include=optional sharp or yarn add sharp --ignore-engines

It's a mess when doing automated builds because you depend on what's defined in package.json

@michaelbromley
Copy link
Member

Hi @meyvan, thanks for the report

Regarding the error itself, it may be the same as reported here

My question is why is included as part of core packages ? Since the entire architecture is strategy based why not let the end user install it IF AND ONLY IF they use SharpAssetPreviewStrategy ?

When you use @vendure/create we do include some non-core plugins that (usually) make the starting experience smoother.

  • AssetServerPlugin
  • EmailPlugin
  • AdminUiPlugin

We do not ship any other asset preview strategy than the sharp one, which means that if we didn't include it in a standard installation, then if you try to upload images we would not be able to create previews.

Can you try updating to Node v20 and see if that makes any difference?

@meyvan
Copy link
Author

meyvan commented Jul 30, 2024

We do not ship any other asset preview strategy than the sharp one, which means that if we didn't include it in a standard installation, then if you try to upload images we would not be able to create previews.

Can you try updating to Node v20 and see if that makes any difference?

@michaelbromley I get it.

But here is my visible confusion:

Screenshot (2)

I see previews being made as optional params, which led me to assume, those are in fact optional

Second, the left panel shows Sharp Preview Strategy similar to AssetStorage and LocalStorage and underneath it. It led me to believe SharpPreview is a separate strategy and not part of Assets Storage.

Maybe can it be included as a submenu underneath AssetStorageStragety ?

@meyvan
Copy link
Author

meyvan commented Jul 30, 2024

I was under the assumption that if no preview related configurations are sent in, then no image will be transformed

@meyvan
Copy link
Author

meyvan commented Jul 30, 2024

Still getting the same error mate, tried 20 and 22

@meyvan
Copy link
Author

meyvan commented Jul 30, 2024

Got it. To anyone who is using windows, use the below for local development and make sure to install the linux based when you are deploying. Not a great solution but the bug from Sharp as mentioned by @michaelbromley makes it as a necessity

npm install sharp
npm install --force @img/sharp-win32-x64

@meyvan meyvan closed this as completed Jul 30, 2024
@ziban
Copy link

ziban commented Jul 30, 2024

@meyvan please reopen it. I'm experiencing the same issue on a linux machine, and I think having a long term solution helps.

@michaelbromley it breaks between version 2.1.9 and 2.2.0. I had to upgrade from an earlier version to use a plugin and ran into this error.
Screen Shot 2024-07-30 at 3 14 33 PM

@michaelbromley
Copy link
Member

in v2.2.0 we upgraded the Sharp version, which is why the issue now appears.

I think a work-around could be that we add the --include=optional flag in the @vendure/create install command. The strange thing is that I don't run into this when testing locally. I'll have to see how I can reproduce and therefore test any fixes.

@michaelbromley michaelbromley moved this to 📋 Backlog in Vendure OS Roadmap Jul 31, 2024
@michaelbromley michaelbromley added @vendure/core @vendure/asset-server-plugin P2: important Critical issue which does not affect majority of users labels Jul 31, 2024
@ziban
Copy link

ziban commented Jul 31, 2024

Some thoughts on reproducing the error:

  1. Maybe installing an earlier version(2.0/2.1) then upgrading might cause the issue.
  2. Using yarn - was able to solve the issue by moving to npm, and running npm install --cpu=x64 --os=linux --libc=glibc sharp and npm install --include=optional sharp

@dlhck dlhck added the status: research needed 🔍 More in-depth research need to make a decision+ label Sep 27, 2024
@dlhck dlhck added this to the v3.0.5 milestone Sep 27, 2024
@dlhck dlhck self-assigned this Sep 27, 2024
@dlhck
Copy link
Collaborator

dlhck commented Oct 4, 2024

2. Using yarn - was able to solve the issue by moving to npm, and running npm install --cpu=x64 --os=linux --libc=glibc sharp and npm install --include=optional sharp

@ziban did that resolve the issue? In case it did I would like to add it to our docs. Thanks!

@ziban
Copy link

ziban commented Oct 8, 2024

Yeah it resolved the issue, but I'm not certain if it will work for everyone.

@floze
Copy link
Contributor

floze commented Oct 14, 2024

FWIW and because I haven't seen it mentioned yet, using yarn install --ignore-engines properly installs the runtime as well, without having to add sharp to the package explicitly.

@dlhck
Copy link
Collaborator

dlhck commented Oct 15, 2024

It seems that this is an issue that is massively dependent on the OS. Right now there is no clear solution for that, a lot of the commands in the comments are a good approach to solve it. I will close this issue for now, if it comes up again we can re-open it at this point.

@dlhck dlhck closed this as completed Oct 15, 2024
@michaelbromley michaelbromley removed this from the v3.0.5 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2: important Critical issue which does not affect majority of users status: research needed 🔍 More in-depth research need to make a decision+ type: bug 🐛 Something isn't working @vendure/asset-server-plugin @vendure/core
Projects
None yet
Development

No branches or pull requests

6 participants