The bcrypt bug on Docker

Oluwaleke Fakorede hashCode
Hacktive Devs
Published in
2 min readAug 16, 2019

I recently faced on bug while using the NodeJs encryption library; bcrypt on Docker.

internal/modules/cjs/loader.js:807

app_1 | return process.dlopen(module, path.toNamespacedPath(filename));

Above is the bug I faced.

source: AirPair

Backstory

I was working on a NodeJs project and I had set up Docker; if you do not know what Docker is, check it out here.

I configured the NodeJs app service in my docker-compose.yml file to use the local node_modules folder, basically: I was using the same node_modules on local development and on Docker on my laptop.

The advantage is that npm install would not have to reinstall all the dependencies when I run docker-compose up.

The bug

I was using bcrypt to hash some data, my app worked locally but when I ran docker-compose up it gave the error above, after many ups and downs, I figured that the bcrypt node modules are different for macOS and Linux OS, and other OS.

I use a MacBook Pro with macOS Mojave but the Docker image was Linux.

argggghh!!!!!

The fix

I had a start.sh file before, so I added two new lines:

my fix
  1. npm uninstall bcrypt would remove bcrypt modules for the other operating system.
  2. npm install bcrypt would install for the current machine that the app would be running on.

Works like magic!

The purpose of writing this is for anyone who encounters this bug in the future, I hope I was able to help.

After conquering that serious bug, I’m feeling like this😅

--

--

Oluwaleke Fakorede hashCode
Hacktive Devs

I love sharing my knowledge in the best way. Software || Data Engineer, mathematician.