0

I'm trying to install Waffle on an M1 Mac.

Per documentation, after creating a fresh new project with npx hardhat, I use npm like this: npm install --save-dev ethereum-waffle

This is the result:

npm ERR! code 1
npm ERR! path /Users/gian/Developer/learning-playground/web3/hardhat-tutorial/node_modules/ganache-core/node_modules/bufferutil
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! CC(target) Release/obj.target/bufferutil/src/bufferutil.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.10 found at "/opt/homebrew/opt/[email protected]/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/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/gian/Developer/learning-playground/web3/hardhat-tutorial/node_modules/ganache-core/node_modules/bufferutil/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/gian/Library/Caches/node-gyp/17.6.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/gian/Library/Caches/node-gyp/17.6.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/gian/Library/Caches/node-gyp/17.6.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/gian/Developer/learning-playground/web3/hardhat-tutorial/node_modules/ganache-core/node_modules/bufferutil',
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! ../src/bufferutil.c:2:10: fatal error: 'assert.h' file not found
npm ERR! #include <assert.h>
npm ERR!          ^~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/bufferutil/src/bufferutil.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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.3.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/17.6.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/gian/Developer/learning-playground/web3/hardhat-tutorial/node_modules/ganache-core/node_modules/bufferutil
npm ERR! gyp ERR! node -v v17.6.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gian/.npm/_logs/2022-03-08T15_26_01_888Z-debug-0.log

Same outcome when downgrading to Node 16.14

1 Answer 1

1

Fixed it by adding these packages:

  • gcc
  • g++
  • libc-dev
  • musl
  • musl-dev

In my case I also had to add (running it on a Node Alpine Docker container)

  • python3
  • make

Not entirely sure why these packages are needed, but I found this solution from this issue.

2
  • Unfortunately many of those libs are not available on MacOS - only on Linux. Thanks for the tip though! Mar 27, 2022 at 12:38
  • I know it's far from ideal, but what you can do is create a devcontainer (if you use VSCode) and run it from inside the container. Helps isolating a lot of these issues.
    – Sebastian
    Mar 31, 2022 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.