Gatsby v1.9 fails to deploy on Ubuntu Focal 20.04

I am self-answering this one to help anyone else who might have similar problems. After the forced upgrade to Ubuntu Focal 20.04, my deploys started failing with the following error.

5:19:26 PM: [4/4] Building fresh packages...
5:19:30 PM: error /opt/build/repo/node_modules/sharp: Command failed.
5:19:30 PM: Exit code: 1
5:19:30 PM: Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

I believe this is due to the old version of Gatsby using an old version of sharp, which is not compatible witht the globally installed lipvips on this image or the default node version.

To solve this, I did the following. Not sure whether it’s all needed, but it’s working now and I’m not going to touch it again.

Set the following environment variables:

  • YARN_VERSION=1.4.0
  • npm_config_sharp_local_prebuilds=./sharp

In my package.json I added

  "resolutions": {
    "sharp": "0.20.8"

Then I added pre-built sharp binaries to the ./sharp path in my repo. I’m running OS X locally so I added for local and Netlify:


Not sure if it mattered, but I also ran yarn locally and pushed the new yarn.lock into my repo.

What a hot mess.

I am sorry you encountered this obstacle, but thanks so much for following up with your solution. This will definitely help future forums members who encounter something similar.