2

I'm trying to run a recently cloned Gatsby project on an M1 Mac and it's failing. Getting the following error:

npm ERR! ERR! sharp Prebuilt libvips 8.10.5 binaries are not yet available for darwin-arm64v8

I've tried brew install vips, followed by npm install as a solution and it has not worked. Really need to get working on this project.

Error log below:

npm ERR! code 1
npm ERR! path /Users/user/Desktop/dev/cassabella/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
npm ERR! CC(target) Release/obj.target/nothing/../node-taddon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   TOUCH Release/obj.target/libvips-cpp.stamp
npm ERR!   CXX(target) Release/obj.target/sharp/src/common.o
npm ERR! info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-darwin-arm64v8.tar.br
npm ERR! ERR! sharp Prebuilt libvips 8.10.5 binaries are not yet available for darwin-arm64v8
npm ERR! info sharp Attempting to build from source via node-gyp but this may fail due to the above error
npm ERR! info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | darwin | arm64
npm ERR! (node:85286) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/user/Desktop/dev/cassabella/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/user/Desktop/dev/cassabella/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/user/Desktop/dev/cassabella/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/user/.node-gyp/16.13.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/user/.node-gyp/16.13.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/user/Desktop/dev/cassabella/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/user/.node-gyp/16.13.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/user/Desktop/dev/cassabella/node_modules/sharp',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! ../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
npm ERR! #include <vips/vips8>
npm ERR!          ^~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/sharp/src/common.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/user/Desktop/dev/cassabella/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/user/Desktop/dev/cassabella/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/user/Desktop/dev/cassabella/node_modules/sharp
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-12-20T21_23_06_624Z-debug.log
Glaser
  • 21
  • 1
  • 1
  • 2

3 Answers3

2

I just tried npm -g i sharp on my M1 MacBook Air and it works, so..there are a few things to know about your machine's environment.

  1. The brew formula is actually called libvips. I didn't have it installed and npm i sharp worked fine without it.

  2. Take a detailed look at https://sharp.pixelplumbing.com/install#custom-libvips and the next section "Building from Source". If you have libvips installed, you may need to set the env var SHARP_IGNORE_GLOBAL_LIBVIPS to ignore it.

  3. Make sure other npm dependencies in package.json are up to date if possible.

  4. As a workaround you could create a i386 arch copy of Terminal or iTerm2, place it in your Applications folder called "iTerm2 Rosetta", or something similar, and use the Get Info dialog on the file to enable Rosetta. You could even set a custom icon for it. enter image description here

Ivan -Oats- Storck
  • 4,096
  • 3
  • 30
  • 39
1

In my case (mac M1), I had to install python as well, apart from installing sharp globally.

1. npm i -g sharp
2. ln -s "$(brew --prefix)/bin/python"{3,}
3. npm ls sharp  --> (to check if sharp is installed or not)
4. npm rebuild --verbose sharp
5. npm i
0

You can use the amd64 binary for npm

brew install nvm
arch -x86_64 zsh
nvm install 18
exit
npm install

https://www.jurnalanas.com/blog/node-js-mac-m1

Peeter Kokk
  • 1,625
  • 2
  • 15
  • 9