barrysteyn / node-scrypt

Scrypt for Node
369 stars 88 forks source link

Invalid ELF header docker #160

Open amosyuen opened 6 years ago

amosyuen commented 6 years ago

I've installed node-gyp and node-scrypt in a ubuntu docker container running on Windows. Install worked fine, I'm doing the install in the docker container so it's not happening on Windows. Requiring node-scrypt gives me this error:

api_1  |   module.js:653
api_1  |   return process.dlopen(module, path._makeLong(filename));
api_1  |                  ^
api_1  |
api_1  | Error: /code/api/src/node_modules/node-scrypt/build/default/scrypt.node: invalid ELF header
api_1  |     at Object.Module._extensions..node (module.js:653:18)
api_1  |     at Module.load (module.js:545:32)
api_1  |     at tryModuleLoad (module.js:508:12)
api_1  |     at Function.Module._load (module.js:500:3)
api_1  |     at Module.require (module.js:568:17)
api_1  |     at require (internal/module.js:11:18)
api_1  |     at Object.<anonymous> (/code/api/src/node_modules/node-scrypt/scrypt.js:1:14)
api_1  |     at Module._compile (module.js:624:30)
api_1  |     at Module._extensions..js (module.js:635:10)
api_1  |     at Object.require.extensions.(anonymous function) [as .js] (/code/api/src/node_modules/babel-register/lib/node.js:152:7)
api_1  |     at Module.load (module.js:545:32)
api_1  |     at tryModuleLoad (module.js:508:12)
api_1  |     at Function.Module._load (module.js:500:3)
api_1  |     at Module.require (module.js:568:17)
api_1  |     at require (internal/module.js:11:18)
api_1  |     at Object.<anonymous> (/code/api/src/app/v1/auth/local/passwords/versions/v0.js:2:1)

If I follow the instructions to natively compile node-scrypt and copy that into my node_modules that works fine.

git clone https://github.com/barrysteyn/node-scrypt.git
cd node-scrypt
npm install
node-gyp configure build
greggmojica commented 6 years ago

Same issue!

murich commented 6 years ago

Same issue except the fix didn't work for me :(

quantumproducer commented 6 years ago

Same, I tried copying over the build output and everything inside of release to the node_modules/node-scrypt directory, no success.

I can run node server.js fine on my local OSX machine, fails on an Ubuntu server.

stanbar commented 6 years ago

Same problem here. Any fixes ?

mseijas commented 6 years ago

I'm having the same issue. Have any of you been able to resolve this?

stanbar commented 6 years ago

I'm not sure what happened, but for me the solution was to reboot

haohaowasky commented 6 years ago

same issue!

beverlycodes commented 6 years ago

Make sure you're doing "npm install" within Dockerfile, and make sure .dockerignore contains **/node_modules

This is commonly a result of having a local node_modules directory get copied into the docker build, which will then cause npm to think that package has already been built within the image. As a result, the scrypt package that was built for your OS winds up inside the image and the container OS understandably can't run it.

pb-expa commented 5 years ago

Tried the above.

Still not working!

pb-expa commented 5 years ago

Actually got it working guys.

For whoever comes across this in the future, the issue DOES comes down to how you handle the node_module folder generation. However, It may not be enough for you to simply .dockerignore it, for me I had to set up docker to explicitly regenerate the node_module folder. This came down to doing 3 things:

1. Dockerfile (make sure you are copying your package.json):

FROM node:8

WORKDIR /usr/src/code

COPY package.json /usr/src/code

RUN yarn install ......

2. .dockerignore (make sure you are ignoring your node_modules)

dump.rdb *.log **/node_modules .....

3. Dockerfile (set up a node_modules folder in the volumes)

version: '3' services: web: build: . ports:

When i did all three of these, the project finally compiled correctly. Hope this helps!