In my case, I'm working with pnpm and had to add the following to my package.json
pnpm
package.json
"pnpm": { ..., "onlyBuiltDependencies": [ "sharp" ] }