Bcrypt: invalid ELF header with Docker and Sails.JS
Make sure that you are not copying the node_modules
folder. I got this error when using the official nodejs "onbuild" image which would copy everything...
Now I use:
.dockerignore
node_modules
dockerfile
FROM node:6.4.0
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "start" ]
EXPOSE 6969
Edit: The official NodeJS Docker starter image project on Github has accepted my pull request for ther README which instructs to explicitly ignore the node_modules.
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.
I was experiencing same thing, even though using Express, not Sails. I tried every suggestion here with no success. What made the trick was change the npm module bcrypt by bcryptjs:
npm uninstall bcrypt
npm install bcryptjs --save
Then change your require to something like
var bcrypt = require('bcryptjs');
It is working flawlessly now.