PlayForm/Compress

Build error in Astro@4.0.8

Closed this issue · 1 comments

I encountered a build error while using Astro4.0.8. Here are the details:

Environment

  • astro@4.0.8
  • astro-compress@2.5.5

Error Message

$ npm run build

[vite] Error when evaluating SSR module /path_to_project/astro.config.mjs: failed to import "astro-compress"
|- Error: Could not load the "sharp" module using the linux-x64 runtime
ERR_DLOPEN_FAILED: libvips-cpp.so.42: cannot open shared object file: No such file or directory
Possible solutions:
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
  or
    npm install --force @img/sharp-linux-x64
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/path_to_project/node_modules/astro-compress/node_modules/sharp/lib/sharp.js:85:9)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/path_to_project/node_modules/astro-compress/node_modules/sharp/lib/constructor.js:10:1)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)

[astro] Unable to load your Astro config

Could not load the "sharp" module using the linux-x64 runtime
ERR_DLOPEN_FAILED: libvips-cpp.so.42: cannot open shared object file: No such file or directory
Possible solutions:
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
  or
    npm install --force @img/sharp-linux-x64

Interestingly, when I downgraded to Astro-compress 2.5.3, the issue was resolved.
I suspect that the issue might be due to a version mismatch between Astro and Astro-compress, specifically with the version of Sharp they are using.

Additionally, I found that adding the following override to the package.json also resolved :

  "overrides": {
    "sharp": "0.33.1"
  },

Thank you for your assistance with this issue.

Duplicate: #244