我有一个旧的node.js应用程序,我正在复活几年前写的。我正在更新其中的包和依赖项,但我遇到了一个严重的问题,该问题阻碍了程序的运行。
每次我尝试使用node app.js或nodemon在myApplication文件夹中启动应用程序时,都会出现以下错误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-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我仍然会遇到同样的失败。需要注意的是,我尝试同时使用node-gyp的全局安装和本地安装。
我特别指出了有问题的软件包bson-ext并使用npm重新安装了它
npm install bson-ext我还去了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我还获取了缺失文件bson.node的一个较旧版本,并粘贴到/Users/myUser/folder/myApplication/node_modules/bson-ext/build/目录中。它给出了一个通知,它是使用旧的节点版本构建的,因此应用程序将无法运行。
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时,我是否缺少一些方法??
发布于 2019-04-03 01:09:34
问题出在bson-ext上。我的应用程序正在搜索版本1.0.5,而版本2.0.1是最新的版本。这就解决了这个问题。
bson-ext的1.0.5版本对nan@2.4.0有内部依赖,而node@v11无法正常工作。
https://stackoverflow.com/questions/55476874
复制相似问题