How to fix 'Something went wrong installing the sharp module' on Netlify

How to fix 'Something went wrong installing the sharp module' on Netlify

If you run into this error, the fix might be easier than you think.

Error: Something went wrong installing the sharp module
Cannot find module '../build/Release/sharp-linux-x64.node'
...

How to fix the issue

  1. Open up the deploy/build page that was unsuccessful.

  2. Click "Retry" then choose "Clear cache and retry"

That's it. You don't have to update the configuration or anything.

If it's a deploy preview, you'd need to do this again to the production context after the PR has been merged. The cache is separate between sites so you'd have to do this for every site.

Other environments

For other environments, maybe you'd have to add --platform and --arch flag when installing dependencies. For example,

pnpm install --platform=linux --arch=x64

The node_modules after installation can't just be copied over to another platform. See also https://github.com/lovell/sharp/issues/3166