withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.79k stars 2.49k forks source link

Sharp causing build issues after upgrading to astro 3.0.3 #8310

Closed sanserna closed 1 year ago

sanserna commented 1 year ago

Astro info

Astro version            v3.0.3
Package manager          pnpm
Platform                 darwin
Architecture             x64
Adapter                  Couldn't determine.
Integrations             None or couldn't determine.

What browser are you using?

Chrome

Describe the Bug

After upgrading Astro from v2.10.9 to v3.0.3 the build command is throwing the below error

 error   Could not find Sharp. Please install Sharp (`sharp`) manually into your project.

The documentation mentions Astro v3.0 includes Sharp as the default image processing service, do I need to install the dependency manually?

What's the expected result?

The build ends successfully.

Link to Minimal Reproducible Example

NA

Participation

jacobdalamb commented 1 year ago

I see something similar

[@astrojs/vercel] The module "sharp" inside the file "/Users/jacoblamb/GitHub/jtlamb.dev/dist/chunks/sharp.7e5222ad.mjs" couldn't be resolved. This may not be a problem, but it's worth checking.
newtoallofthis123 commented 1 year ago

I had the same issue while building and deploying. There seems to be some weird issue with the dependency management.

You can just fix the problem by manually installing sharp

npm install sharp@latest
motheki commented 1 year ago

I am experiencing the same issue building with the latest version of Astro. I attempted to follow @newtoallofthis123 's instructions and added sharp@latest to my dependencies within the package.json and received the same error.

  "dependencies": {
    "@astrojs/prefetch": "latest",
    "astro": "latest",
    "wrangler": "latest",
    "sharp": "latest"
  },

My Specs:

Astro version            v3.0.3
Package manager          bun
Platform                 darwin
Architecture             aarch64
Adapter                  N/A (none)
Integrations             N/A (none).

This issue is also observable in the astro bun template located in the documentation:

bunx create-astro@latest my-astro-project-using-bun --template eliancodes/brutal

if you migrate to the latest version of astro.

Astro ^2.10.3 does not encounter this issue (as long as you enable the formerly experimental assets feature in the config).

Princesseuh commented 1 year ago

As mentioned on the page of the error, strict package managers like pnpm require a manual install.

I'm not sure for Bun however, we don't support it officially so I've never investigated how it works (and it could very well be an issue upstream for them)

Princesseuh commented 1 year ago

I see something similar

[@astrojs/vercel] The module "sharp" inside the file "/Users/jacoblamb/GitHub/jtlamb.dev/dist/chunks/sharp.7e5222ad.mjs" couldn't be resolved. This may not be a problem, but it's worth checking.

This one is normal, sharp is external on Vercel. It should still work! Though the hint message is admittedly threatening

newtoallofthis123 commented 1 year ago

It works for me for some unknown reason.... I am just using npm

jacobdalamb commented 1 year ago

It works for me for some unknown reason.... I am just using npm

its just for pnpm users that see this error

natemoo-re commented 1 year ago

I'm not sure if there's anything we can do here, but we'll need to discuss whether this is something we can fix.

jacobdalamb commented 1 year ago

@sanserna This should be fixed in the latest version.

Princesseuh commented 1 year ago

We fixed the warning showing on Vercel build and added note in some places in docs about this:

image

During the beta we tried to find a way to fix this for pnpm users but couldn't find anything. Other projects that use Sharp in a similar fashion are also affected by this issue.

I'll close the issue since there's nothing actionable at this time.

bugenzi commented 3 months ago

I had the same issue while building and deploying. There seems to be some weird issue with the dependency management.

You can just fix the problem by manually installing sharp

npm install sharp@latest

Sadly for me it stopped working :(, did not change anything just added mdx

FelixSelter commented 1 month ago

I can confirm that this happens with older versions of nodejs. I upgraded from node19 to node22 and now its working with pnpm