Node 16 officially supports Mac M1 (ARM) architecture. The mongo driver works and according to the docs the field level encryption is compatible with the driver, but when installing mongodb-client-encryption on Mac m1 node 16, I get an error:
npm ERR! code 1
npm ERR! path /Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption
npm ERR! command failed
npm ERR! command sh -c prebuild-install --tag-prefix node-v || node-gyp rebuild
npm ERR! CXX(target) Release/obj.target/mongocrypt/src/mongocrypt.o
npm ERR! prebuild-install WARN install No prebuilt binaries found (target=16.10.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.10.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! (node:89775) [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 /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/florianbischoff/.nvm/versions/node/v16.10.0/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/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/florianbischoff/.nvm/versions/node/v16.10.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/florianbischoff/Library/Caches/node-gyp/16.10.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/florianbischoff/Library/Caches/node-gyp/16.10.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/florianbischoff/.nvm/versions/node/v16.10.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/florianbischoff/Library/Caches/node-gyp/16.10.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption',
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! In file included from ../src/mongocrypt.cc:1:
npm ERR! ../src/mongocrypt.h:8:10: fatal error: 'mongocrypt/mongocrypt.h' file not found
npm ERR! #include <mongocrypt/mongocrypt.h>
npm ERR! ^~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/mongocrypt/src/mongocrypt.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/florianbischoff/.nvm/versions/node/v16.10.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194: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 "/Users/florianbischoff/.nvm/versions/node/v16.10.0/bin/node" "/Users/florianbischoff/.nvm/versions/node/v16.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption
npm ERR! gyp ERR! node -v v16.10.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
Any idea how to solve this?
From the error it seemed like node-gyp had no idea where libmongocrypt was installed. I followed the installation docs from libmongocrypt/README.md at 317c7e5fa986c6bccf12d1d89ebfb2afb8f3fe54 · mongodb/libmongocrypt · GitHub
brew install mongodb/brew/libmongocrypt
Running CPLUS_INCLUDE_PATH=/opt/homebrew/include npm install gives others errors
npm ERR! code 1
npm ERR! path /Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption
npm ERR! command failed
npm ERR! command sh -c prebuild-install --tag-prefix node-v || node-gyp rebuild
npm ERR! CXX(target) Release/obj.target/mongocrypt/src/mongocrypt.o
npm ERR! SOLINK_MODULE(target) Release/mongocrypt.node
npm ERR! prebuild-install WARN install No prebuilt binaries found (target=14.17.6 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.6 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/florianbischoff/.nvm/versions/node/v14.17.6/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/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/florianbischoff/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/florianbischoff/Library/Caches/node-gyp/14.17.6/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/florianbischoff/Library/Caches/node-gyp/14.17.6',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/florianbischoff/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/florianbischoff/Library/Caches/node-gyp/14.17.6/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption',
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/mongocrypt.cc:33:13: warning: unused function 'StringFromBinary' [-Wunused-function]
npm ERR! std::string StringFromBinary(mongocrypt_binary_t* binary) {
npm ERR! ^
npm ERR! ../src/mongocrypt.cc:68:17: warning: unused function 'BooleanOptionValue' [-Wunused-function]
npm ERR! NAN_INLINE bool BooleanOptionValue(v8::Local<v8::Object> options,
npm ERR! ^
npm ERR! 2 warnings generated.
npm ERR! clang: error: no such file or directory: '/Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption/deps/lib/libmongocrypt-static.a'
npm ERR! clang: error: no such file or directory: '/Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption/deps/lib/libkms_message-static.a'
npm ERR! clang: error: no such file or directory: '/Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption/deps/lib/libbson-static-1.0.a'
npm ERR! make: *** [Release/mongocrypt.node] 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/florianbischoff/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/Users/florianbischoff/.nvm/versions/node/v14.17.6/bin/node" "/Users/florianbischoff/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/florianbischoff/Repositories/datev-konverter/node_modules/mongodb-client-encryption
npm ERR! gyp ERR! node -v v14.17.6
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
@Florian_Bischoff did you ever solve this? I am having the exact same issue and cannot yet work out a way around it.
There is a workaround described here: https://jira.mongodb.org/browse/NODE-3631 Sadly the bug is still unresolved.
Thanks @Florian_Bischoff for now I have opted to run my terminal using rosetta which seems to avoid the issue.