Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
A native module compiled for macOS/Windows is being loaded on Linux.
Seen on:
npm
Meaning
.node binaries are platform-specific. Copying node_modules into a Docker image or server from another OS causes it.
Common causes
- node_modules copied from the host into the container
- Shared volume between host and container
⚡ Quick fix
- Exclude node_modules via .dockerignore and run npm ci in the image
- Rebuild: npm rebuild
Detailed fix by platform
Docker
- bash
COPY package*.json ./ RUN npm ci COPY . .
How to diagnose
- Build — Where was node_modules created?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026