Closed SyedMuzamilM closed 11 months ago
Hi, @SyedMuzamilM, can you provide more information on your environment, the OS, hosting provider, stuff like that, so that we can investigate it further?
In the meantime, you can try running the #no-sharp branch, which disables image compression, but removes this error. To install it just replace the package.json
entry for astro-compress
with:
{
"astro-compress": "astro-community/AstroCompress#no-sharp"
}
or:
npm install -D -E astro-community/AstroCompress#no-sharp
OS is windows 10 and I deployed it to Cloudflare Pages and Vercel both gave the same error.
Will try this command and see if it works.
Which Node version are you using?
There are similar issues in the sharp repository. Maybe try npm ls sharp
as per https://github.com/lovell/sharp/issues/3896#issuecomment-1857516925 and see if there's a version mismatch somewhere in your code or with an outdated dependency.
Which Node version are you using?
I am using the latest node version 20.10.0
There are similar issues in the sharp repository. Maybe try
npm ls sharp
as per https://github.com/lovell/sharp/issues/3896#issuecomment-1857516925 and see if there's a version mismatch somewhere in your code or with an outdated dependency.
Will check the and see if this works.
The previous command worked fine which doesn't use sharp. It is now getting deployed properly.
Will check if any other dependency is using sharp so that the error could be resolved.
Hey @NikolaRHristov I've the same error on my M1 MBA. I'm on Node v20.10.0.
Installing astro compress:
> joshua@MacBook-Air-von-Joshua x-website % yarn add astro-compress --save-dev
yarn add v1.22.19
[1/4] π Resolving packages...
[2/4] π Fetching packages...
warning sharp@0.33.0: The engine "libvips" appears to be invalid.
warning @img/sharp-libvips-darwin-arm64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-darwin-arm64@1.0.0: The engine "macos" appears to be invalid.
warning @img/sharp-darwin-arm64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-darwin-arm64@0.33.0: The engine "glibc" appears to be invalid.
warning @img/sharp-darwin-x64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-darwin-x64@0.33.0: The engine "glibc" appears to be invalid.
warning @img/sharp-libvips-darwin-x64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-darwin-x64@1.0.0: The engine "macos" appears to be invalid.
warning @img/sharp-libvips-linux-arm@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linux-arm@1.0.0: The engine "glibc" appears to be invalid.
warning @img/sharp-libvips-linux-arm64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linux-arm64@1.0.0: The engine "glibc" appears to be invalid.
warning @img/sharp-libvips-linuxmusl-arm64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linuxmusl-arm64@1.0.0: The engine "musl" appears to be invalid.
warning @img/sharp-libvips-linux-x64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linux-x64@1.0.0: The engine "glibc" appears to be invalid.
warning @img/sharp-libvips-linuxmusl-x64@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linuxmusl-x64@1.0.0: The engine "musl" appears to be invalid.
warning @img/sharp-libvips-linux-s390x@1.0.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-libvips-linux-s390x@1.0.0: The engine "glibc" appears to be invalid.
warning @img/sharp-linux-arm@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linux-arm@0.33.0: The engine "glibc" appears to be invalid.
warning @img/sharp-linux-s390x@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linux-s390x@0.33.0: The engine "glibc" appears to be invalid.
warning @img/sharp-win32-ia32@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-wasm32@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linuxmusl-x64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linuxmusl-x64@0.33.0: The engine "musl" appears to be invalid.
warning @img/sharp-win32-x64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linux-arm64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linux-arm64@0.33.0: The engine "glibc" appears to be invalid.
warning @img/sharp-linuxmusl-arm64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linuxmusl-arm64@0.33.0: The engine "musl" appears to be invalid.
warning @img/sharp-linux-x64@0.33.0: The engine "pnpm" appears to be invalid.
warning @img/sharp-linux-x64@0.33.0: The engine "glibc" appears to be invalid.
[3/4] π Linking dependencies...
warning " > postcss-css-variables@0.19.0" has unmet peer dependency "postcss@^8.2.6".
warning " > postcss-variable-compress@3.0.0" has unmet peer dependency "postcss@^8.2.8".
[4/4] π¨ Building fresh packages...
success Saved lockfile.
success Saved 42 new dependencies.
info Direct dependencies
ββ astro-compress@2.2.5
info All dependencies
ββ @jridgewell/source-map@0.3.5
ββ @types/css-tree@2.3.4
ββ @types/csso@5.0.3
ββ @types/html-minifier-terser@7.0.2
ββ ansi-sequence-parser@1.1.1
ββ array-union@2.1.0
ββ astro-compress@2.2.5
ββ buffer-from@1.1.2
ββ camel-case@4.1.2
ββ clean-css@5.3.3
ββ dir-glob@3.0.1
ββ dot-case@3.0.4
ββ fs-extra@10.1.0
ββ globby@11.1.0
ββ html-minifier-terser@7.2.0
ββ ignore@5.3.0
ββ jsonc-parser@3.2.0
ββ jsonfile@6.1.0
ββ lower-case@2.0.2
ββ lunr@2.3.9
ββ marked@4.3.0
ββ param-case@3.0.4
ββ pascal-case@3.1.2
ββ path-type@4.0.0
ββ relateurl@0.2.7
ββ sharp@0.33.0
ββ shiki@0.14.7
ββ slash@3.0.0
ββ source-map-support@0.5.21
ββ svgo@3.1.0
ββ terser@5.26.0
ββ typedoc-plugin-keywords@1.6.0
ββ typedoc-plugin-mdn-links@3.1.7
ββ typedoc-plugin-merge-modules@5.1.0
ββ typedoc-plugin-remove-references@0.0.6
ββ typedoc-plugin-rename-defaults@0.7.0
ββ typedoc-plugin-zod@1.1.0
ββ typedoc@0.25.4
ββ typescript-esbuild@0.3.3
ββ typescript@5.3.3
ββ vscode-oniguruma@1.7.0
ββ vscode-textmate@8.0.0
β¨ Done in 13.56s.
Running ls sharp:
> joshua@MacBook-Air-von-Joshua x-website % npm ls sharp
x-website@0.0.1 /Users/joshua/DEV/x-website
βββ¬ astro-compress@2.2.5
β βββ sharp@0.33.0
βββ¬ astro@3.6.4
βββ sharp@0.32.6
My dependencies:
"devDependencies": {
"@astrojs/sitemap": "^3.0.3",
"@astrojs/tailwind": "^5.0.2",
"@storyblok/astro": "^3.0.1",
"@vitejs/plugin-basic-ssl": "^1.0.2",
"astro": "^3.6.4",
"astro-critters": "^2.0.11",
"astro-compress": "^2.2.5",
"astro-purgecss": "^3.2.1",
"astro-rename": "^1.1.2",
"lightningcss": "^1.22.1",
"postcss-css-variables": "^0.19.0",
"postcss-variable-compress": "^3.0.0",
"prettier": "^3.1.0",
"prettier-plugin-astro": "^0.12.2",
"prettier-plugin-tailwindcss": "^0.5.7",
"purgecss": "^5.0.0",
"tailwindcss": "^3.3.6",
"vite": "^5.0.5"
},
"dependencies": {
"@astrojs/prefetch": "^0.4.1",
"@fontsource-variable/inter": "^5.0.15",
"astro-icon": "^0.8.1"
}
I see, astro
3.6.4 is running an older version of sharp
than astro-compress
npm ls sharp
βββ¬ astro-compress@2.2.5
β βββ sharp@0.33.0
βββ¬ astro@3.6.4
βββ sharp@0.32.6
Can you try pinning the version of sharp
for astro
with the same one astro-compress
uses? This is done by updating the package.json
to override the dependency like so:
package.json
{
"name": "your-project",
"version": "1.0.0",
"dependencies": {
"astro": "3.6.4",
"astro-compress": "2.2.5"
},
"resolutions": {
"sharp": "0.33.0"
}
}
or
package.json
{
"overrides": {
"astro": {
"sharp": "0.33.0"
}
}
}
Update: resolutions
works only on Yarn
. Use the overrides
method.
Since astro:image
uses sharp as its default image service, I think that might be causing issues when using astro-compress
Astro Default Image Service you can check it here.
@NikolaRHristov Forcing it to v0.33.0 works perfectly fine. Thank you!
Can you try pinning the version of
sharp
forastro
with the same oneastro-compress
uses? This is done by updating thepackage.json
to override the dependency like so:package.json
"resolutions": { "sharp": "0.33.0" }
This fixed it for me! Thank you for your work
Interesting⦠setting "resolutions": {"sharp": "0.32.6"}
worked with my M1 MacBook Air, but setting it to 0.33.0
resulted in the error:
[vite] Error when evaluating SSR module /Users/kswedberg/Sites/ks/blog.karlswedberg.com/astro.config.mjs: failed to import "astro-compress"
|- Error: Could not load the "sharp" module using the darwin-arm64 runtime
Interesting⦠setting
"resolutions": {"sharp": "0.32.6"}
worked with my M1 MacBook Air, but setting it to0.33.0
resulted in the error:[vite] Error when evaluating SSR module /Users/kswedberg/Sites/ks/blog.karlswedberg.com/astro.config.mjs: failed to import "astro-compress" |- Error: Could not load the "sharp" module using the darwin-arm64 runtime
Use:
{
"overrides": {
"astro": {
"sharp": "0.33.0"
}
}
}
resolutions
is supported only on Yarn.
@NikolaRHristov , I'm using Yarn. Thanks for the suggestion, but neither resolutions
nor overrides
worked with sharp 0.33.0. Maybe I need to leave it set as "resolutions": {"sharp": "0.32.6"}
β unless you have another idea I can try.
@NikolaRHristov , I'm using Yarn. Thanks for the suggestion, but neither
resolutions
noroverrides
worked with sharp 0.33.0. Maybe I need to leave it set as"resolutions": {"sharp": "0.32.6"}
β unless you have another idea I can try.
Well, the version of sharp
depends on the AstroCompress
and Astro
versions and whichever you choose to override. I'm just suggesting overrides
as a general solution since resolutions
is only supported on Yarn.
I'll see if I can implement something dynamic that overrides the AstroCompress
sharp
version pre-install to match Astro
's sharp
version.
Well, the version of sharp depends on the AstroCompress and Astro versions and whichever you choose to override
Yeah, I get that. All I'm saying is that astro build
fails with the error when I "choose to override" using 0.33.0
, while it works with 0.32.6
. In case it helps at all, I'm using astro 3.4.0 and astro-compress 2.2.5. And here is the (truncated) stdout of yarn why sharp
:
=> Found "sharp@0.33.0"
info Reasons this module exists
- "astro-compress" depends on it
- Hoisted from "astro-compress#sharp"
=> Found "astro#sharp@0.32.6"
info This module exists because "astro" depends on it.
I'll see if I can implement something dynamic that overrides the AstroCompress sharp version pre-install to match Astro's sharp version.
That would be wonderful. Thanks so much!
{ "overrides": { "astro-compress": { "sharp": "0.32.6" } } }
Does this work?
No, "overrides": {"astro-compress": {"sharp": "0.32.6"}}
didn't work for me. I'll just keep using "resolutions": {"sharp": "0.32.6"}
until some later version irons out the issues. thanks again
No,
"overrides": {"astro-compress": {"sharp": "0.32.6"}}
didn't work for me. I'll just keep using"resolutions": {"sharp": "0.32.6"}
until some later version irons out the issues. thanks again
@kswedberg I'm sorry, can I use you to debug something else? Does the resolutions
method work for sharp
0.33.1
with the latest AstroCompress
and Astro
?
No problem, happy to help. Trying it with "resolutions": {"sharp": "0.33.1"}
did not work, unfortunately. astro build
produced this:
12:29:08 PM [vite] Error when evaluating SSR module /Users/kswedberg/Sites/ks/blog.karlswedberg.com/astro.config.mjs: failed to import "astro-compress"
|- Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
... [a bunch of stuff] ...
[astro] Unable to load your Astro config
error Could not load the "sharp" module using the darwin-arm64 runtime
Thank you so much! We will investigate this further, for now glad that the resolutions
hotfix works with sharp
0.32.6
and both Astro
and AstroCompress
installed.