image icon indicating copy to clipboard operation
image copied to clipboard

`sharp` optional binaries not included in `.output`

Open Aareksio opened this issue 1 year ago • 6 comments

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.

Aareksio avatar Feb 20 '24 18:02 Aareksio

I couldn't get it working with pnpm and supportedArchitectures. Had to go back to Yarn... 😟

tasiotas avatar Feb 20 '24 19:02 tasiotas

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

alimozdemir avatar Feb 25 '24 22:02 alimozdemir

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.

juane1000 avatar Mar 21 '24 15:03 juane1000

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.

DamianGlowala avatar Apr 09 '24 13:04 DamianGlowala

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.

oripka avatar Apr 26 '24 12:04 oripka

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"
}

oripka avatar Jul 26 '24 13:07 oripka