Issue with Sharp Module on Netlify

I am experiencing an issue with the Sharp module while deploying my application on Netlify. I am using Node.js version 20.11.0, and my netlify.toml file is configured as follows:

[build]
command = "npm run build"
publish = ".next"
environment = { NODE_VERSION = "20.11.0" }

[dev]
command = "npm run dev"
port = 8888

[functions]
external_node_modules = ["sharp"]
included_files = ["node_modules/sharp/**/*"]

The build process completes successfully, and the website works fine. However, I encounter a 500 error when making a POST request to the endpoint /api/retrieval/retrieve. This endpoint works correctly on my local environment and on Vercel, but I am facing this issue only on Netlify.

Here are the relevant logs from Netlify:

I have attempted the following steps to resolve the issue:

  1. Installed the latest version of Sharp, but I received errors during the build process.
  2. Run the command npm install --ignore-scripts=false --foreground-scripts --verbose sharp to get more information.
  3. Executed npm install --platform=linux --arch=x64 sharp to ensure compatibility with the Netlify environment.

Unfortunately, none of these steps have resolved the issue.

Could anyone provide guidance on how to solve this problem?

Same issue here:

Are you doing anything with sharp in your server-side functionality?

did u find solution?