Installing Gatsby v2 on an M1 Mac 🔧

Recently had to install a legacy NodeJS project that needed to stay on Gatsby v2.32.13 and found a few opaque errors, and eventually a solution, that I thought I'd share.

The problem

I was getting the following error when trying to install the Gatsby project locally on an M1 mac via npm install:

../src/ fatal error: 'vips/vips8' file not found
#include <vips/vips8>
1 error generated.
make: *** [Release/] Error 1
Note: This assumes you already use Node v16+ for the M1 support

As it turns out, the error is due to a nested dependency Sharp - relevant GitHub issue here (opens in a new tab).

I had to update a feature on this legacy Gatsby project and as mentioned, the project could not be upgraded to a Gatsby version with M1 support.

To fix this error, I was able to separately install vips with a package manager that I already use on macOS: homebrew (opens in a new tab).

The solution

It turns out that installing a newer version of vips with homebrew does the trick. I was able to install vips v8.11.5 with the following command:

arch -arm64 brew install vips
Note: I use homebrew to install x64 packages on my M1 mac, so I had to specify the architecture with arch -arm64 to install the package for the M1 chip.

You may be prompted to install the Xcode command line tools, but that's it.

Fortunately going forward, projects on Gatsby v3+ don't have this issue as M1 support has been patched.

Last Updated: Fri Dec 16 2022

Related Posts

How I'm building this website 🛠

Wed Oct 12 2022

Looking for more posts?

© Gabriel Uribe.RSS