Docker Community Forums

Share and learn in the Docker community.

Error while docker run for Node JS application : Error: /usr/src/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header

Hi All,

I am not sure if this is the right place to post this issue.

I am new to both Docker and Node JS and trying to develop one small node JS application which works fine in my local system but whenever I am trying to run a docker with my Node Js application I am getting below error::

Using ts-node version 8.0.3, typescript version 3.3.4000
Error: /usr/src/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
at Module._extensions…node (internal/modules/cjs/loader.js:977:18)
at Object.nodeDevHook [as .node] (/usr/src/app/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object. (/usr/src/app/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Module._extensions…js (internal/modules/cjs/loader.js:947:10)
at Object.nodeDevHook [as .js] (/usr/src/app/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object. (/usr/src/app/src/controllers/v0/users/routes/auth.router.ts:20:29)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Module.m._compile (/tmp/ts-node-dev-hook-3851647523043238.js:55:25)
at Module._extensions…js (internal/modules/cjs/loader.js:947:10)
at require.extensions. (/tmp/ts-node-dev-hook-3851647523043238.js:57:14)
at Object.nodeDevHook [as .ts] (/usr/src/app/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
[ERROR] 20:55:40 Error: /usr/src/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header

Please let me know if you have any suggestions for it.

Thanks,
SwapWagh

  1. Create a .dockerignore file in the root of your app and add: node_modules