Something went wrong installing the "sharp" module. Module did not self-register.

February 22, 2020

I spent more time than I'd care to admit today trying to debug why my Github Actions workflow to automatically deploy new versions of on push to master was failing. The site is built on Gatsby, and the pipeline runs gatsby build, but I was running into the following error on every push:

Something went wrong installing the "sharp" module

Module did not self-register.

- Remove the "node_modules/sharp" directory, run "npm install" and look for errors
- Consult the installation documentation at
- Search for this error at

Given how many different people have reported symptoms of what looks like the same issue, I figured I'd shared what worked for my case.

The root cause of this issue seems to be that folks are trying to run gatsby build with a version of node which is different than the one they installed sharp with. In my case, I used to have the workflow set up do deploy like this:

- name: Build and Deploy
  uses: JamesIves/github-pages-deploy-action@db4aacadf4db71778afb0c8a452382184a71d318
      ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
      BRANCH: gh-pages
      FOLDER: public
      BUILD_SCRIPT: npm run gatsby-build

github-pages-deploy-action is a great github action that automatically pushes a given local folder to your gh-pages branch to deploy via Github Pages. The version I was using ran everything in a Docker container and excuted the given BUILD_SCRIPT before pushing. I think this was the issue - that container most likely had a different version of node.

The most recent release of this action gets rid of the BUILD_SCRIPT entirely, opting to let the workflow build its own folder first, and the action just takes care of pushing the build folder. The working workflow looks like this:

- name: npm run gatsby-build
  run: npm run gatsby-build
- name: Build and Deploy
    uses: JamesIves/github-pages-deploy-action@releases/v3
      ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
      BRANCH: gh-pages
      FOLDER: public

Single responsibilities make everything easier for everyone 👍

Picture of me with a corgi

Noah Gilmore

Hello! I'm Noah, a software developer based in the San Francisco bay area. I focus mainly on iOS, Apple platform development, and full stack web development.

  • 💻 I'm writing a macOS editor for Atlassian Confluence called Fluency
  • 📱 I wrote an app which lets you create transparent app icons called Transparent App Icons
  • 🧩 I made a puzzle game for iPhone and iPad called Trestle
  • 🎨 I wrote a CoreImage filter utility app for iOS developers called
  • 👋 Please feel free to reach out on Twitter