Skip to main content

Sharp error mac m1

· One min read
Hung Viet Nguyen

When running command yarn to install dependencies for a Gatsby project on Mac M1, I encounter this error with sharp:

error /Users/myname/myrepo/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
Directory: /Users/myname/myrepo/node_modules/sharp
info sharp Downloading
ERR! sharp Prebuilt libvips 8.9.1 binaries are not yet available for darwin-arm64v8
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see for required dependencies
gyp info it worked if it ends with ok

The reason is sharp does not work work well with Mac M1 (yet), the solution is you should reinstall vips package on your Mac as follow:

  1. xcode-select --install
  2. brew install gcc
  3. brew reinstall vips
  4. brew info vips
  5. npm i

Please see for more.

If this does not resolve your problem, try with Node 14.

If this still does not resolve your problem, follow this (

brew remove vips
rm -rf node_modules
yarn install