Invalid ELF header with node bcrypt on AWSBox

2019-05-26 11:05发布

问题:

I'm playing with awsbox and deploying my app shows these errors:

    /home/app/code/node_modules/mongoose-troop/node_modules/bcrypt/node_modules/bindings/bindings.js:79
            throw e
                  ^
    Error: /home/app/code/node_modules/mongoose-troop/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
        at Object.Module._extensions..node (module.js:485:11)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Module.require (module.js:362:17)
        at require (module.js:378:17)
        at bindings (/home/app/code/node_modules/mongoose-troop/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
        at Object.<anonymous> (/home/app/code/node_modules/mongoose-troop/node_modules/bcrypt/bcrypt.js:1:97)
        at Module._compile (module.js:449:26)
        at Object.Module._extensions..js (module.js:467:10)
        at Module.load (module.js:356:32)
    warn: Forever detected script exited with code: 1
    warn: Forever restarting script for 1 time

Any idea how to resolve this?

回答1:

[edit] I had the same error for another reason (see comments), just in case it works for someone else: I solved it by re-installing the bcrypt module by npm with this command:

npm install bcrypt


回答2:

Not sure what the best answer might be but I did find some post mentioning something about x86 vs 64 bit issues. I deleted the mongoose-troop module and called npm install from within the awsbox console and that seemed to have done it. Not sure how that will work as far as deploying to awsbox though. Might not work



回答3:

Please reinstall your bcrypt module by npm install then restart the server. Should be solved.