[500] [IPX_ERROR] Something went wrong installing the "sharp" module when visiting .netlify url

Hi, I am at https://development--techinterviewcoach.netlify.app

all seems to be working well on netlify, but I am facing issues working locally. Redirects seems to have broken - for example, I have the following redirect in the netlify.toml

[[redirects]]
  # ...or serve a resized version
  from = "/cdn/:width/*"
  to = "/.netlify/images?url=/images/:splat&width=:width"
  status = 200

and it’s failing, example when I visit http://localhost:8888/cdn/120/trustpilot-white.png in the CLI I get:

ERROR '/cdn/120/trustpilot-white.png' not found.

opening that url in the page returns the following json file:

{
  "error": {
    "message": "[500] [IPX_ERROR] \nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-darwin-arm64v8.node'\nRequire stack:\n- /Users/andrea.dellacorte/Documents/Github/techinterview.coach/node_modules/.pnpm/sharp@0.32.6/node_modules/sharp/lib/sharp.js\n- /Users/andrea.dellacorte/Documents/Github/techinterview.coach/node_modules/.pnpm/sharp@0.32.6/node_modules/sharp/lib/constructor.js\n- /Users/andrea.dellacorte/Documents/Github/techinterview.coach/node_modules/.pnpm/sharp@0.32.6/node_modules/sharp/lib/index.js\n\nPossible solutions:\n- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"\n- Install for the current darwin-arm64v8 runtime: \"npm install --platform=darwin --arch=arm64v8 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install"
  }
}

I have recently moved from npm to pnpm; can that be the cause?

I have run

npm_config_platform=darwin npm_config_arch=arm64v8 pnpm install sharp

but it did not help

I also added

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

to my netlify.toml, and that did not help either

Does this relative path exist at the time you run the site local?

Wait, shouldn’t you be running the terminal version as x64 when using node to be compatible with what netlify uses?

Does this relative path exist at the time you run the site local?

It does not… I am not sure what this folder is, tbh

Wait, shouldn’t you be running the terminal version as x64 when using node to be compatible with what netlify uses?

I tried to follow the instructions you linked but the error persists.

This is what I tried. I managed to change the install an x64 version of node:

➜  techinterview.coach git:(development) ✗ node -p 'process.arch'
x64
➜  techinterview.coach git:(development) ✗ node -v
v23.6.0

then rm -rf node_modules and ran pnpm install; I had to add this to my package.json to avoid some version mismatches:

"pnpm": {
    "supportedArchitectures": {
      "os": ["darwin", "current"],
      "cpu": ["arm64", "x64"]
    }
  }

this didn’t help. I am still facing the same errors when running netlify dev.

Ok, so the build path is the path where the Sharp package is trying to resolve the compiled package to run. Since this is a Netlify function the sharp package needs to be packaged with the function. This is typically done by using a package.json in the function and it get’s included when the function compiles.

Not sure what’s going on with this build, since I don’t have a copy and see the paths being built. Another issue is Netlify CLI does some custom path copying during local dev that I haven’t unraveled for myself, because I typically handle it myself.

This won’t make you feel better, but Sharp is famous for all these issues and I stopped using it a long time ago.

This won’t make you feel better, but Sharp is famous for all these issues and I stopped using it a long time ago.

I am not really using it… it’s a dependency of a dependency of netlify cli?

Anyway, thanks for the help so far.

I’ve tried moving back to npm from pnpm…

➜  techinterview.coach git:(development) ✗ node -v
v23.6.0
➜  techinterview.coach git:(development) ✗ node -p 'process.arch'
arm64

Good news is that I can now see my images when I run npx netlify dev; I can see them working in the page and I can load them if I type the the address to them via the cdn redirect…

Bad news is… I still get a lot of errors from netlify cli?

[2025-01-16 22:45:21] ERROR '/cdn/16/companies/back.png' not found.
◈ Rewrote URL to /.netlify/images?url=/images/companies/back.png&width=16

also, I have a redirect from / to /tech which has always worked and would automagically redirect me when I loaded the netlify localhost:8888 url… and that’s not happening anymore (didn’t work on pnpm either).

Glad to hear going back to npm fixed the path resolution issue. Good luck with the rest of the errors.

Downgraded to netlify-cli@v17.38.1 and everything works well - not sure what I am doing wrong

This might just be an issue with the CLI

This sometimes happened to me. Installing sharp myself fixes it. And then it works even when sharp is uninstalled.

what commands did you use to fix it? I tried everything :frowning:

npm i sharp and then remove it from package.json and run npm i again.