ノードアプリの実行時にbcryptの無効なelfヘッダーが発生する 質問する

ノードアプリの実行時にbcryptの無効なelfヘッダーが発生する 質問する

私は学校の Node.js プロジェクトに取り組んでいます。npm で bcrypt をインストールできなかったので、bcrypt-nodejs をインストールしたところ、昨日はプロジェクトは正常に動作しました。しかし、今日、「node app」を実行すると、次のエラーが発生します。

/.../node_modules/bcrypt/node_modules/bindings/bindings.js:79
        throw e
              ^
Error: /.../node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at bindings (/.../node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
    at Object.<anonymous> (/.../node_modules/bcrypt/bcrypt.js:1:97)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

私の package.json ファイルは次のようになります:

{
  "name": "Supinfarm",
  "version": "0.0.0",
  "env": {
              "PYTHON": "/usr/bin/python2.6"
        },
  "dependencies": {
    "express": "3.1.0",
    "connect-flash": "*",
    "jade": "*",
    "stylus": "*",
    "passport": "*",
    "passport-local": "*",
    "mongoose": "*",
    "bcrypt": "*"
  }
}

私は Linux ubuntu 10.04 LTS を使用しています。Google で解決策を見つけようとしましたが、うまくいきませんでした... 誰か助けてくれませんか?

ベストアンサー1

私はそれを見つけましたOSXでコンパイルされたbcryptはLinuxではうまく動作しないつまり、ローカル OSX ワークステーションでコンパイルされた bcrypt をチェックインし、Linux サーバーでノード アプリを実行しようとすると、上記のエラーが表示されます。

解決策: npm install bcryptLinux では、チェックインすると解決します。

おそらく、これに対処する最善の方法は、.gitignore で node_modules を除外し、リモートで npm install することです。

おすすめ記事