node.js - npm 安装返回错误。显示 "no such file directory ../node_modules/mongodb-client-encryption/deps/lib/...'

标签 node.js mongodb npm next.js

我有一个非常大的 NextJS 项目正在进行,使用 mongodb 但我无法在其上运行 npm install,因为它给出了以下错误。

npm ERR! code 1
npm ERR! path <PATH TO PROJECT>/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! sh: <PATH TO PROJECT>/node_modules/.bin/prebuild-install: Permission denied
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.1 | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '<PATH TO PROJECT>/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   '<PATH TO PROJECT>/node_modules/mongodb-client-encryption/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '<PATH TO PROJECT>/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/<MACOS USER NAME>/Library/Caches/node-gyp/16.13.1/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/<MACOS USER NAME>/Library/Caches/node-gyp/16.13.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=<PATH TO PROJECT>/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/<MACOS USER NAME>/Library/Caches/node-gyp/16.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=<PATH TO PROJECT>/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: '<PATH TO PROJECT>/node_modules/mongodb-client-encryption/deps/lib/libmongocrypt-static.a'
npm ERR! clang: error: no such file or directory: '<PATH TO PROJECT>/node_modules/mongodb-client-encryption/deps/lib/libkms_message-static.a'
npm ERR! clang: error: no such file or directory: '<PATH TO PROJECT>/

我已经尝试重新安装 Node 和 npm。有问题的包似乎是 mongodb-client-encryption 但我不确定是什么导致了这个错误。

出现这个错误后,我检查了我的文件,没有创建node_modules/mongodb-client-encryption目录。

我在运行:

  • MacOS 蒙特雷
  • npm -v 8.1.2
  • Node -v v16.13.1

我知道最近有一篇帖子 ( https://www.mongodb.com/community/forums/t/install-mongodb-client-encryption-on-mac-m1-node-16/125728 ) 有类似的错误,但那里概述的解决方案没有奏效。谁能帮帮我?

最佳答案

This one帮助了我,特别是博客中的这一部分:

I ran into an issue with libmongocrypt when I tried to run my code, because libmongocrypt was trying to statically link against libmongocrypt instead of dynamically linking. I have submitted an issue to the team to fix this issue, but to fix it, I had to run: export BUILD_TYPE=dynamic

所以在尝试 npm 安装之前在终端中运行它。

export BUILD_TYPE=dynamic

关于node.js - npm 安装返回错误。显示 "no such file directory ../node_modules/mongodb-client-encryption/deps/lib/...',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70960675/

相关文章:

node.js - Yandex Disk API 无法使用访问 token node.js 发出请求

node.js - 如何使用 Node.js 代码获取所有 mongoDB 集合名称?

node.js - sails.js 中验证的完整示例

arrays - 更新嵌套数组 Mongoose

npm install 因多层本地依赖项而失败

reactjs - 类型错误 : Failed to load plugin 'jest' declared in '.eslintrc' : Class extends value undefined is not a constructor or null

node.js - 在 Ubuntu 13.10 上安装 Phonegap

jquery - (浏览器作为客户端)$.ajax 上的 HTTP 405 POST 到 Node 服务

mongodb - 对 NoSQL 设计的困惑

mongodb - 如何在 mongodb 的 spring-data 中映射枚举集合