Elf Header or Installation Issue with Bcrypt in Docker Container

Bcrypt: invalid ELF header with Docker and Sails.JS

In my package config I had "bcrypt":"^0.8.0" and when I took out the ^ and changed it to "bcrypt":"0.8.0" I was able to get everything running.

The issue was that it was trying to run bcrypt 0.8.5 and that was causing issues for some reason.

bcrypt and Docker bcrypt_lib.node: invalid ELF header

I have found that excluding the entire local node_modules directory does not allow you to install npm packages and have your docker container track those changes in the container on the fly. In order to have other package changes tracked specify only the bcrypt directory in the container volume:

- .:/app
- /app/node_modules/bcrypt/

Invalid ELF header with node bcrypt on AWSBox

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

ERROR: /ng-app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header

This is mostly a guess. But your step 7 copies all the files in your current context to /ng-app (including any node_modules folder you might have). If this node_modules folder contains binaries and they were installed on macOS or Windows then they would be the wrong architecture for the container (which would be Linux).

A simple fix for this particular case would be to exclude the node_modules folder by adding it to your .dockerignore file (https://docs.docker.com/engine/reference/builder/#dockerignore-file). This would prevent node_modules from being copied to the resulting container and the node_modules from the npm install at step 4 would be used instead.

Invalid ELF Header on Production Server

I found the answer because I installed bcrypt on a Windows machine, but the production server is running Linux meant that it didn’t have the correct files to work with.

I fixed it by installing bcrypt on a Linux machine and then uploading it to the hosting server.

Related Topics

Leave a reply