Meteor 2.3.5: bcrypt_lib.node: invalid ELF header

After upgrading to 2.3.5 from 2.2 I encountered the following issue: when I build bundle with meteor build --architecture os.linux.x86_64 I get this error on Ubuntu:


Error: /opt/booco/programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1131:18)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Module.Mp.load (/opt/booco/programs/server/runtime.js:46:33)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/opt/booco/programs/server/npm/node_modules/meteor/accounts-password/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Module.Mp._compile (/opt/booco/programs/server/runtime.js:99:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Module.Mp.load (/opt/booco/programs/server/runtime.js:46:33)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at npmRequire (/opt/booco/programs/server/npm-require.js:133:12)

Checked with old version (2.2) - everything works fine.
The error can be fixed if I run ‘npm rebuild bcrypt’ from /opt/booco/programs/server/npm/node_modules/meteor/accounts-password/.

Still I believe that something was broken in meteor build in 2.3.5…

Facing the same during a deplyment on aws. Meteor 2.4.

I think this happened to me also because of the nodejs update from 12 to 14 in Meteor 2.3.
Various brypt versions work with specific nodejs versions, there is a table in the readme:

I did not face it in 2.3. But now after I encountered in 2.4, even on reverting I keep getting the same error. bcrypt is the latest 5.0.1

Which tool/service are you using for deployments? This type of error is usually caused by the deployment tool not rebuilding native npm packages, or doing so with a different node version than the version it uses to run the app.

You need bcrypt native implementation to fix this it’s npm -g i bcrypt inside the node_modules of the build, make sure you have gcc installed or clang package installed to compile it. Not sure if can be fixed with a deployment tool or not, I deploy by hand with meteor build and scp the tarball to the server.

I had the same, but oddly enough I had already upgraded to 2.4 and it was only a later release of mine. Because it was in a staging environment I had a time to play and none of the above suggestions worked, which was odd, but my deployment tools are home grown from a long time ago. From the bundle directory I used to cd programs/server and run an npm install to make sure it was all compatible with the node version I was running. However, looking at package.json, I actually tried npm run install instead and that actually fixed it. It may or may not work for you.

1 Like

It worked for me to use npm run install. I share my dockerfile:

FROM node:14.18.2

COPY /opt/
RUN unzip -q && cd bundle/programs/server && npm install && npm run install
WORKDIR /opt/bundle



CMD ["node", "main.js"]

Meteor 2.5.3

1 Like

THANK YOU. This fixed it for me. I returned to Meteor 2.5, could not get app to work with 2.5.3 but then still had trouble. Uninstalled Node and Meteor, reboot, installed Meteor 2.5 and Node v14.18.3, and Building on Win10 64 → os.linux.x86_64, a Digital Ocean Ubuntu 20.04 64 with Node v14.18.2 – been fighting fibers all day. THIS worked. Thank you sir.