Closed MDmubarak786 closed 10 months ago
What is the output of npm ls sharp
βββ¬ astro-compress@2.2.7
β βββ sharp@0.33.1
βββ¬ astro@4.1.1
β βββ sharp@0.33.1
βββ sharp@0.32.6
@NikolaRHristov here we go
Usually you don't need sharp
installed separately and Astro
's version of sharp
must match AstroCompress
's version of sharp
.
To do so you can override the version of sharp
to match either Astro
's or AstroCompress
's by doing this:
If Astro
uses an older version of sharp
:
{
"overrides": {
"astro": {
"sharp": "0.33.1"
}
}
}
or:
{
"overrides": {
"astro-compress": {
"sharp": "0.33.1"
}
}
}
If AstroCompress
uses an older version of sharp
.
Again, this depends on the output of npm ls sharp
and the latest version of sharp
available.
βββ¬ astro-compress@2.2.7 β βββ sharp@0.33.1 βββ¬ astro@4.1.1 β βββ sharp@0.33.1 βββ sharp@0.32.6
@NikolaRHristov here we go
In your case, just remove sharp
from the dependencies list and the issue should be fixed as both are using the same version 0.33.1
.
To fix it "once and for all" for every future version of Astro
and AstroCompress
just override both to use the same version:
{
"overrides": {
"astro-compress": {
"sharp": "0.33.1"
},
"astro": {
"sharp": "0.33.1"
}
}
}
I will make a version of AstroCompress
that accounts for the version mismatch between the two, but for now this https://github.com/astro-community/AstroCompress/issues/257#issuecomment-1879794233 is a pretty ok hotfix.
Sorry I tried but it didn't work
{
"name": "astro-ultimate-tutorial",
"version": "0.0.1",
"scripts": {
"commit": "git-cz",
"-------- build, dev --------------------------------------------------------------": "-",
"dev": "astro dev",
"build": "astro build",
"-------- start, please use this for local for run this in 3000 port --------------": "-",
"start": "astro dev --port 3000",
"preview": "astro preview",
"astro": "astro",
"-------- schema management--------------------------------------------------------": "-",
"sync:components": "sb-mig sync components --all --presets"
},
"devDependencies": {
"@astrojs/tailwind": "^5.0.4",
"@storyblok/astro": "^4.0.0",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-basic-ssl": "^1.0.2",
"astro": "^4.0.8",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vite": "^5.0.10"
},
"dependencies": {
"@astrojs/partytown": "^2.0.3",
"@astrojs/react": "^3.0.8",
"@astrojs/sitemap": "^3.0.4",
"@astrojs/vercel": "^6.1.1",
"@camped-ui/aspect-ratio": "^2.0.2",
"@camped-ui/avatar": "^2.0.2",
"@camped-ui/button": "^2.0.2",
"@camped-ui/calendar": "^2.0.2",
"@camped-ui/card": "^2.0.2",
"@camped-ui/lib": "^1.0.8",
"@camped-ui/textarea": "^2.0.2",
"astro-compress": "^2.2.7",
"astro-robots": "^2.0.0",
"astro-seo": "^0.8.0",
"astrojs": "^0.1.3",
"clsx": "^2.0.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sb-mig": "^5.2.2",
"storyblok-schema-types": "^1.1.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"overrides": {
"astro-compress": {
"sharp": "0.33.1"
},
"astro": {
"sharp": "0.33.1"
}
}
}
βββ¬ astro-compress@2.2.7 overridden β βββ sharp@0.33.1 overridden βββ¬ astro@4.1.1 overridden βββ sharp@0.33.1 deduped
Does it work without the overrides, since both are using the same version?
No, not working
βββ¬ astro-compress@2.2.7
β βββ sharp@0.33.1
βββ¬ astro@4.1.1
βββ sharp@0.33.1 deduped
No, not working
βββ¬ astro-compress@2.2.7 β βββ sharp@0.33.1 βββ¬ astro@4.1.1 βββ sharp@0.33.1 deduped
hmm, I will investigate it further. Thank you for your feedback. In the meantime you can install AstroCompress
from the #no-sharp
branch like so:
npm install -D -E astro-community/AstroCompress#no-sharp
There is an issue in the sharp
repository which tracks this: https://github.com/lovell/sharp/issues/3870 and here https://github.com/vercel/nft/issues/371 in the Vercel
nft
repository.
sure thanks,
am getting this error
|- SyntaxError: Unexpected token '<<'
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)
I don't know how to do it with Yarn
, but just replace the astro-compress
entry in your package.json
with the following:
{
"dependencies": {
"astro-compress": "astro-community/AstroCompress#no-sharp",
}
}
am getting this error
|- SyntaxError: Unexpected token '<<' at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)
AstroCompress
's #no-sharp branch had recent merges lately. This should now be fixed.
My Packages
Please tell me the workaround to fix this