Gabriel Uribe

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.

Link to this headingThe problem

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

../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] 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.

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.

Link to this headingThe 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.

Link to this headingRelated

Link to this headingLooking for more posts?

Looking for a full-stack Next.js/iOS/visionOS developer for your project? Email us at hello@skyporch.co.