image
image copied to clipboard
`sharp` optional binaries not included in `.output`
Reproduction
git clone [email protected]:nuxt/image.git
cd image
pnpm install
pnpm dev:prepare
pnpm build
pnpm dev:build
rm -rf node_modules/@img
node playground/.output/server/index.mjs
Open: http://localhost:3000/provider/ipx
[500] [IPX_ERROR] Could not load the "sharp" module using the ... runtime
Sharp binaries, bundled as @img/sharp-*
, are not included in generated .output
. Tests may pass, because of module resolution. We need to isolate .output
(or delete root project node_modules
, as with reproduction), as it should be done in production.
Related: https://github.com/lovell/sharp/issues/4000 (cross architecture build) Related: #1237, #1210 (either cross architecture build or isolating .output) Related: #1253 (both cross architecture build and isolating .output)
Workaround before this gets fixed: downgrade sharp
to 0.32.6
via your package manager.
I couldn't get it working with pnpm
and supportedArchitectures
. Had to go back to Yarn... 😟
This is a blocker for me right now, either I will remove nuxt-image or I will find a workaround with pnpm. It is very annoying
The latest update (1.4.0) shoots my server build to 50MB+ from ~12-ishh. Is this intentional/desirable? Seem exorbitant. I was unaware that the the plugin included resizing functionality. Is there an option to exclude the "sharp" dependency from the server bundle and have it installed in the deployment server environment? Thanks.
Has anyone found a workaround with pnpm? This is also a blocker for me at the moment.
UPDATE: added sharp 0.33.3 (or higher) to overrides and it works correctly.
Has anyone found a workaround with pnpm? This is also a blocker for me at the moment.
UPDATE: added sharp 0.33.3 to overrides and it works correctly.
This is the only fix that worked for me, everything else described even using the latest nuxt image version failed when deploying a nuxt project built on m1 to a linux x64 server.
I just moved to a monorepo setup and had to include nuxt-image
and the override in the root package.json in order to make this work. First I had nuxt-image
as a dependency in the base layer and no matter where I applied overrides it would not work.
{
"devDependencies": {
"@nuxt/image": "^1.7.0"
},
"pnpm": {
"overrides": {
"sharp": "0.33.4"
},
"supportedArchitectures": {
"os": [
"current",
"linux"
],
"cpu": [
"x64",
"arm64"
]
}
},
"packageManager": "[email protected]+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
}