6 months ago
Starting Container
npm warn config production Use --omit=dev instead.
> server@1.0.0 start
> node server.js
node:internal/modules/cjs/loader:1460
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Module._extensions..node (node:internal/modules/cjs/loader:1460:18)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12) {
code: 'ERR_DLOPEN_FAILED'
}
Node.js v18.20.5
npm warn config production Use --omit=dev instead.
3 Replies
6 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open chandrika • 6 months ago
6 months ago
Please provide more info. When is this error happening? Your build command? Possible package.json. Cause it looks like maybe it was build on another OS than the one on Railway or some kind of encoding thingy:Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header - that's the main issue
You should build your app on Railway so there are no version/OS problems. Please give more info :)
6 months ago
Hi,
This issue is usually caused by compiling the bcrypt binary on your local machine, which is a different environment than the one the Railway container runs in.
A good way to attempt fixing this issue would be to make sure your node_modules are added to your .gitignore file and that you are not uploading those to GitHub.
If the issue still persists after checking the above it might be a good idea to consider using bcryptjs instead.
If you could provide more context (such as your full build command, package.json file) I'd be able to look further for you.
I'd really appreciate if you could accept this answer if it solves your problem! Thanks 
joshjaminio
Hi,This issue is usually caused by compiling the bcrypt binary on your local machine, which is a different environment than the one the Railway container runs in.A good way to attempt fixing this issue would be to make sure your node_modules are added to your .gitignore file and that you are not uploading those to GitHub.If the issue still persists after checking the above it might be a good idea to consider using bcryptjs instead.If you could provide more context (such as your full build command, package.json file) I'd be able to look further for you.I'd really appreciate if you could accept this answer if it solves your problem! Thanks
6 months ago
These look correct - try it out? If you need debugging help, share you package.json