-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Cannot build when using Sharp 0.33.0 #9345
Comments
Could you provide a reproduction? I'm building many websites using Sharp 0.33.0 and Astro 4 successfully both locally and in CI with no issues. |
Hello @Boston343. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Working on trying to replicate on Stackblitz and haven't been able to yet. Might try a local copy of the same code to see if anything changes. |
@Princesseuh I added a stackblitz link, although you'll need to download it to your machine and install npm packages, then attempt to build. I added an additional comment which I've copied here. I'm not sure if this is an astro problem or an astro-compress problem but it seems to be an interaction between the two. Additional notes: It seems to be an interaction between astro:assets and astro-compress. If I even have the line But again, if I downgrade sharp to 0.32.6, this issue doesn't happen. So maybe it's a sharp issue? I really have no idea how to diagnose further unfortunately. |
I'm having trouble building using the most recent sharp version too. Downgrading sharp to 0.32.6 helped me as well. Happy to provide a reproducible example if needed still! P.S. this is my first project working with Astro and it has been an absolute treat! A big thank you to everyone involved in the work on the project! |
Hmm, following the reproduction steps, everything seems to work just fine for me. One thing I do notice with the |
When I dump the actual error, I get the following exception:
Turns out, Sharp 0.33.0 changed how binaries are distributed (tldr: lovell/sharp#3750 (comment)). The fix for me was to run |
Had the same error in OP since 0.33.0 was released. Remember to clear asset cache between changing versions to force error. Using pnpm on Debian 11 (devcontainer). Can recreate using a new |
I had the same problem installing my site on my server using Installing |
@Princesseuh 4.0.8/#9463 didn't resolve it unfortunately. All deps using same version yet it fails 😞
|
Hmm, that's annoying. I unfortunately do not know, and I still cannot reproduce any issues myself. A question: What version of Node are you using? |
v18.16.0 |
Ah, then I know the issue, Sharp's binaries lowest supported version is ^18.17.0. Try upgrading to at least 18.17.0 (the full semver check is That's unfortunate, wonder why it's that version specifically, we might have to pin until the next major of Astro... so annoying. |
I'm new to JS/TS world, but shouldn't it complain during |
No, because those are all optionalDeps, the JS world doesn't handle dependencies like this super well, unfortunately... |
Scratch that. Forgot to wipe node_modules after changing versions. v18.17.0+ works - and reproducable in codespace with 18.16.0 🥳 Sorry for not testing that. Haven't touched node version since last Astro requirement change. @Boston343 You mentioned v18.18.2 in OP. Have you deleted Update
|
I was getting a build failure on Cloudflare pages: |
Astro v4.0.8 Using npm run dev in development works. But as soon as i host it on Vercel : https://louis-lecocq.vercel.app/ |
@fflaten yeah I've deleted node_modules, along with dist, and .astro folders at various points and it doesn't seem to help. Currently running Node v20.10.0 and npm 10.2.3, otherwise same stuff as original post I'm getting intermittent errors now with Sharp even while in dev mode with Astro 4.0.8 where it says "Could not find Sharp.", when it could just 2 minutes ago, without me even closing the dev environment (just updating a file so it reloads). I have not managed to find consistency with what causes it. Right now I'm working with 4.0.7 and it seems fine. Seems like Sharp ^0.33.0 is just causing problems. |
This issue only occurs after migrating to Node: v20.10.0 I'm getting these warnings about
Error:
|
4.1.0 includes no changes to this, so it's most likely a coincidence! |
It could be. I tried upgrading to |
Downgrading to |
|
I had a problem to render any image on Astro v4.0.8 using the built in If you are getting errors / warnings about missing Sharp or images beeing undefined even though the path you give to src is correct then try
I don't know if it's the proper way to fix that but I'm finally able to render the image... Thanks you good people on this thread :D |
For me all tips here weren't enough, I had to update pnpm itself with |
Thanks |
Just to confirm that for me as well, I just needed to update my versions of node and npm. I use nvm, so it was a matter of: |
|
In my case, I solved this issue for build but not for astro dev ??? TL;DR
Before this issue appear to me, I am using only Then I wanted to use astro
With sharp 0.32.6 manual install :
Finally when I deactivate pwaAssets integration from I see :
Thank you for your clarifications. |
For the moment, my workaround choices are :
|
It seems like the PWA plugin you're using is using an outdated version of Sharp perhaps? Recent versions of Astro assume Sharp 0.33.x |
|
This worked for me. |
For me to fix:
|
For me to fix:
|
Thanks @Giovannisabces ! This worked for me too |
I still encountered this
|
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
If I upgrade the Sharp dependency to 0.33.0 for image optimization with astro:assets, I am unable to build locally (
npm run build
). Development mode still works fine.This happens with both Astro v3.6.4 and v4.0.2.
The error logged to the console looks like:
Additional notes: It seems to be an interaction between astro:assets and astro-compress. If I even have the line
import compress from "astro-compress"
insideastro.config.mjs
the build will fail (I don't even have to add it to the integrations arrray). However, if I remove the compress() integration, and comment out the import statement, it will build fine. THEN I can add the astro-compress import and integration back into the integrations array and it will build and compress fine. But if I then go and add an image or otherwise cause the images to need re-generated (since they aren't cached), the issue will occur again. And then you'll have to do the comment out compress and what-not all over again.If I downgrade sharp back to 0.32.6 it builds just fine.
What's the expected result?
The website should build and this error should not be thrown.
Link to Minimal Reproducible Example
Stackblitz link. You need to download it, run
npm install
, thennpm run build
to see the error. See the "Additional notes" section above for more details.Participation
The text was updated successfully, but these errors were encountered: