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:
- Installed the latest version of Sharp, but I received errors during the build process.
- Run the command
npm install --ignore-scripts=false --foreground-scripts --verbose sharp
to get more information. - 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?