Bcrypt: invalid ELF header with Docker and Sails.JS

a 夏天 提交于 2019-11-30 13:08:20

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.

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 bcrypt-nodejs:

npm uninstal bcrypt
npm install bcrypt-nodejs --save

Then change your require to something like

var bcrypt   = require('bcrypt-nodejs');

It is working flawlessly now.

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.

just to add a new possible cause. I tried to build my docker image for a nodejs app but i've gotthe error invalid ELF header. In my case i ve resolved the issue by adding the node_modules/* from the .dockerignore file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!