Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

node.js - bcrypt invalid elf header when running node app

I'm working on a nodejs project for school. I wasn't able to install bcrypt with npm so i installed bcrypt-nodejs and the project worked fine yesterday. But today, when I do a "node app" i have this error :

/.../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)

my package.json file looks like this:

{
  "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": "*"
  }
}

I'm on Linux ubuntu 10.04 LTS I've tried to find a solution on google without success... Can somebody help me?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've found that bcrypt compiled on OSX will not quite work on Linux. In other words, if you check in the bcrypt compiled on your local OSX workstation, and try to run the node app on your linux servers, you will see the error above.

Solution: npm install bcrypt on Linux, check that in, solved.

Probably the best way to deal with this is exclude your node_modules in .gitignore... and npm install remotely.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...