簡體   English   中英

在 node.js 應用程序中啟動時無法找到綁定文件

[英]Cannot locate bindings file on startup in node.js app

我有一個舊的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/目錄中。 它給出了一個通知,它是使用舊節點版本構建的,因此應用程序將無法運行。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM