Astro build failing due to astro-compress dependency

[vite] Error when evaluating SSR module /opt/buildhome/repo/astro.config.mjs: failed to import "astro-compress"
11:18:19.066	|- Error: Could not load the "sharp" module using the linux-x64 runtime
11:18:19.067	Possible solutions:
11:18:19.067	- Add platform-specific dependencies:
11:18:19.067	    npm install --os=linux --cpu=x64 sharp
11:18:19.068	  or
11:18:19.068	    npm install --force @img/sharp-linux-x64
11:18:19.068	- Consult the installation documentation: https://sharp.pixelplumbing.com/install
11:18:19.068	    at Object.<anonymous> (/opt/buildhome/repo/node_modules/sharp/lib/sharp.js:85:9)
11:18:19.068	    at Module._compile (node:internal/modules/cjs/loader:1233:14)
11:18:19.068	    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
11:18:19.068	    at Module.load (node:internal/modules/cjs/loader:1091:32)
11:18:19.069	    at Module._load (node:internal/modules/cjs/loader:938:12)
11:18:19.069	    at Module.require (node:internal/modules/cjs/loader:1115:19)
11:18:19.069	    at require (node:internal/modules/helpers:119:18)
11:18:19.069	    at Object.<anonymous> (/opt/buildhome/repo/node_modules/sharp/lib/constructor.js:10:1)
11:18:19.069	    at Module._compile (node:internal/modules/cjs/loader:1233:14)
11:18:19.069	    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
11:18:19.069	
11:18:19.069	[astro] Unable to load your Astro config
11:18:19.069	
11:18:19.538	Could not load the "sharp" module using the linux-x64 runtime
11:18:19.539

This is the output I am getting.

Did you try the solutions in the error message?

It was still giving error

Want to give more info? Was the error different? What else have you tried?

There was the same error. But when I removed astro-compress dependency it worked but then UI broke.

I was able to solve this problem with the following in my package.json

  "resolutions": {
    "astro/sharp": "0.33.1",
    "astro-compress/sharp": "0.33.1"
  },

Apparently:

  • More than one version of sharp is pulled in on different import paths
  • They have made some dramatic changes, so having multiple versions breaks the build
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.