Invalid ELF header caused by bcrypt
Asked Answered
C

4

8

I followed this solution:

bcrypt is breaking my meteor application, how do I fix it?

But Im still getting this error:

    /home/kaleobox/bundle/programs/server/node_modules/fibers/future.js:245
                                                    throw(ex);
                                                          ^
    Error: /home/kaleobox/bundle/programs/server/npm/npm-bcrypt/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 (/home/kaleobox/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
        at Object.<anonymous> (/home/kaleobox/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:3:35)
        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)

I went into /home/kaleobox/bundle/programs/server/node_modules and did:

rm -R /home/kaleobox/bundle/programs/server/node_modules/bcrypt

then

npm install bcrypt

but the error above persists. The line

/home/kaleobox/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header

tells me I may have to remove and reinstall bcrypt in that second location?

Contrarious answered 8/4, 2015 at 20:36 Comment(0)
C
4

You should reinstall bcrypt from

/home/kaleobox/bundle/programs/server/npm/npm-bcrypt/node-modules

instead of

/home/kaleobox/bundle/programs/server/node_modules

Closehauled answered 1/10, 2015 at 20:41 Comment(2)
Thank you for posting an answer to this question! Code-only answers are discouraged on Stack Overflow, because it can be difficult for the original poster (or future readers) to understand the logic behind them. Please, edit your question and include an explanation of your code so that others can benefit from your answer. Thanks!Lissie
How does one use your suggestion through npm?Emden
F
1

I have solved this problem by re-installing the bcrypt package in the below directory:

  • Access to this directory:

    /my_app/programs/server/npm/npm-bcrypt/

  • Then run npm install bcrypt

  • Start your app again. It should be fine. :)

Fondue answered 29/4, 2016 at 13:52 Comment(0)
V
0

As @lingxiao-sun's answer indicates, you may find that copying the bcrypt in /home/kaleobox/bundle/programs/server/node_modules into /home/kaleobox/bundle/programs/server/npm/npm-bcrypt/node-modules will fix this issue.

This is possibly because the bcrypt in <your project>/bundle/programs/server/node_modules will have been built/installed locally to the host machine, whereas the bcrypt in /server/npm/npm-bcrypt/node-modules/ will likely be from a source/build machine, and if these environments differ it can cause issues due to the specific binaries required for each environment.

Volution answered 22/4, 2016 at 12:38 Comment(0)
M
0

The problem is you committed your bcrypt executable which was in Windows architecture, but Heroku virtual environments are Linux.

Add node_modules to your .gitignore and use git rm -r --cached node_modules.

The command will remove node_modules from your Git repository and, in your next push, changes to node_modules will be ignored.

Mallis answered 15/11, 2022 at 12:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.