[英]Cannot locate bindings file on startup in node.js app
I have an old node.js
app that I'm resurrecting that I wrote a couple years ago.我有一个旧的
node.js
应用程序,我正在复活我几年前写的。 I'm updating the packages and dependencies inside it, but I've run into a major problem that prevents the program from running.我正在更新其中的包和依赖项,但遇到了阻止程序运行的主要问题。
Each time I try to initiate the application while inside the myApplication
folder, using either node app.js
or nodemon
, I get the following error 22 times:每次我尝试在
myApplication
文件夹中启动应用程序时,使用node app.js
或nodemon
,我都会收到以下错误 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' ] }
Some background information:一些背景资料:
sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D109
node -v
v11.13.0
npm -v
6.7.0
I have tried a number of things to get it to work, and have gone through a variety of other stack overflow threads.我尝试了很多方法来让它工作,并且经历了各种其他堆栈溢出线程。 Initially I tried to use:
最初我尝试使用:
npm update
npm install
This updated all the packages to their current form, but did not eliminate the error.这将所有包更新为当前形式,但并没有消除错误。 I made sure that
xcode-select
was installed and updated.我确保安装并更新了
xcode-select
。 Still, same error.仍然,同样的错误。
I moved on to remove the entire node_modules
folder and rebuilt it using this code:我继续删除整个
node_modules
文件夹并使用以下代码重建它:
npm install node-gyp -g
npm cache clean -f
rm -rf node_modules
npm install
I get the following install runtime output telling me that there are issues with bson-ext
and node bin/postinstall
我得到以下安装运行时输出,告诉我
bson-ext
和node 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
I still get the same failure.我仍然遇到同样的失败。 As a note, I tried to use both a global and local installation for
node-gyp
.请注意,我尝试对
node-gyp
使用全局和本地安装。
I specifically called out the offending package, bson-ext
and used npm
to reinstall it我特意调出了有问题的包
bson-ext
并使用npm
重新安装了它
npm install bson-ext
I also went down the node-gyp
and python
rabbit hole我也去了
node-gyp
和python
兔子洞
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
I also took an older version of the missing file, bson.node
, and pasted into the /Users/myUser/folder/myApplication/node_modules/bson-ext/build/
directory.我还获取了丢失文件
bson.node
的旧版本,并将其粘贴到/Users/myUser/folder/myApplication/node_modules/bson-ext/build/
目录中。 It gave a notice that it was built using an old node version and as a result the application won't run.它给出了一个通知,它是使用旧节点版本构建的,因此应用程序将无法运行。
The package.json
file includes the appropriate dependencies: 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"
}
}
How can I fix the issue that I'm having so that this program will run?如何解决我遇到的问题,以便该程序能够运行? Is there some way that I'm missing for
bson.node
to be created??有什么方法可以让我创建
bson.node
吗?
The problem was with bson-ext
.问题出在
bson-ext
。 My application was searching for version 1.0.5
, while version 2.0.1
was the newest version.我的应用程序正在搜索版本
1.0.5
,而版本2.0.1
是最新版本。 This fixed the problem.这解决了问题。
Version 1.0.5
of bson-ext
had an internal dependency on nan@2.4.0
, which was not functioning with node@v11
. bson-ext
1.0.5
版本对nan@2.4.0
有一个内部依赖,它不能与node@v11
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.