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.
I was getting the following error when trying to install the Gatsby project locally on an M1 mac via
../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 (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).
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 -arm64to 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
Looking for more posts?
My Monthly 4-1-1
Tech-centric newsletter with 4 thoughts, 1 personal win, and 1 hack