gpt4 book ai didi

node.js - 在 Node.js 应用程序中启动时无法找到绑定(bind)文件

转载 作者:太空宇宙 更新时间:2023-11-03 23:59:23 24 4
gpt4 key购买 nike

我有一个旧的 node.js 应用程序,我正在恢复我几年前编写的应用程序。我正在更新其中的包和依赖项,但遇到了一个阻止程序运行的主要问题。

每次我尝试在 myApplication 文件夹内使用 node app.jsnodemon 启动应用程序时,我都会得到出现以下错误 22 次:

{ Error: Could not locate the bindings file. Tried:
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/build/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/build/Debug/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/build/Release/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/out/Debug/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/Debug/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/out/Release/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/Release/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/build/default/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/compiled/11.13.0/darwin/x64/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/release/install-root/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/debug/install-root/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/default/install-root/bson.node
→ /Users/myUser/folder/myApplication/node_modules/bson-ext/lib/binding/node-v67-darwin-x64/bson.node
at bindings (/Users/myUser/folder/myApplication/node_modules/bindings/bindings.js:126:9)
at Object.<anonymous> (/Users/myUser/folder/myApplication/node_modules/bson-ext/ext/index.js:10:30)
at Module._compile (internal/modules/cjs/loader.js:805:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
at Module.require (internal/modules/cjs/loader.js:711:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/Users/myUser/folder/myApplication/node_modules/bson-ext/index.js:1:12)
tries:
[ '/Users/myUser/folder/myApplication/node_modules/bson-ext/build/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/build/Debug/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/build/Release/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/out/Debug/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/Debug/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/out/Release/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/Release/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/build/default/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/compiled/11.13.0/darwin/x64/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/release/install-root/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/debug/install-root/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/addon-build/default/install-root/bson.node',
'/Users/myUser/folder/myApplication/node_modules/bson-ext/lib/binding/node-v67-darwin-x64/bson.node' ] }

一些背景信息:

sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D109
node -v
v11.13.0
npm -v
6.7.0

我尝试了很多方法来让它工作,并且经历了各种其他堆栈溢出线程。最初我尝试使用:

npm update
npm install

这将所有包更新为其当前形式,但并没有消除错误。我确保 xcode-select 已安装并更新。尽管如此,还是同样的错误。

我继续删除整个 node_modules 文件夹并使用以下代码重建它:

npm install node-gyp -g
npm cache clean -f
rm -rf node_modules
npm install

我收到以下安装运行时输出,告诉我 bson-extnode bin/postinstall 存在问题

> fsevents@1.2.7 install /Users/myUser/folder/myApplication/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/myUser/folder/myApplication/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" is installed via remote

> bson-ext@1.0.5 install /Users/myUser/folder/myApplication/node_modules/bson-ext
> (node-gyp rebuild 2> builderror.log) || (exit 0)


> nodemon@1.18.10 postinstall /Users/myUser/folder/myApplication/node_modules/nodemon
> node bin/postinstall || exit 0

added 1044 packages from 1088 contributors and audited 15069 packages in 10.556s
found 0 vulnerabilities

我仍然遇到同样的失败。请注意,我尝试对 node-gyp 使用全局和本地安装。

我特别指出了有问题的软件包 bson-ext 并使用 npm 重新安装它

npm install bson-ext

我还深入了解了node-gyppython兔子洞

node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@11.13.0 | darwin | x64
gyp http GET https://nodejs.org/download/release/v11.13.0/node-v11.13.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v11.13.0/node-v11.13.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v11.13.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v11.13.0/SHASUMS256.txt
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/myUser/folder/myApplication/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/myUser/.node-gyp/11.13.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/myUser/.node-gyp/11.13.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/myUser/.node-gyp/11.13.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/myUser/folder/myApplication',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp: binding.gyp not found (cwd: /Users/myUser/folder/myApplication) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:193:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:255:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.13.0/bin/node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/myUser/folder/myApplication
gyp ERR! node -v v11.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

我还获取了丢失文件的旧版本bson.node,并将其粘贴到/Users/myUser/folder/myApplication/node_modules/bson-ext/build/ 目录。它发出通知,它是使用旧 Node 版本构建的,因此应用程序将无法运行。

package.json 文件包含适当的依赖项:

{
"name": "myApplication",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"angular-daterangepicker": "^0.2.3-alpha1",
"angular-nvd3": "^1.0.9",
"bindings": "^1.5.0",
"body-parser": "^1.18.3",
"bootstrap-daterangepicker": "^2.1.30",
"bson": "^4.0.2",
"bson-ext": "^1.0.5",
"cookie-parser": "^1.4.4",
"debug": "^3.2.6",
"express": "^4.16.4",
"grunt": "^1.0.4",
"jquery": "^3.3.1",
"moment": "^2.24.0",
"mongodb-extended-json": "^1.10.1",
"mongoose": "^5.4.20",
"morgan": "^1.9.1",
"node-gyp": "^3.8.0",
"nodemon": "^1.18.10",
"npm": "^6.9.0",
"pug": "^2.0.3",
"selectize": "^0.12.6",
"serve-favicon": "^2.5.0"
}
}

如何解决我遇到的问题以便该程序能够运行?我是否缺少某种创建 bson.node 的方法??

最佳答案

问题出在 bson-ext 上。我的应用程序正在搜索版本 1.0.5,而版本 2.0.1 是最新版本。这解决了问题。

bson-ext 版本 1.0.5 内部依赖于 nan@2.4.0,该依赖项无法与 node@v11 一起运行。

关于node.js - 在 Node.js 应用程序中启动时无法找到绑定(bind)文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55476874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com