Node-gyp: Error relocating /app/node_modules/bcrypt/build/Release/bcrypt_lib.node: __snprintf_chk: symbol not found

Created on 19 Jun 2017  路  5Comments  路  Source: nodejs/node-gyp

I have a base docker image I use for my builds with node v7 installed. I use it to npm install and then copy everything in a fresh docker image that is based on alpine (node:7-alpine). I am getting the following error when running tests in my alpine container:

Error: Error relocating /app/node_modules/bcrypt/build/Release/bcrypt_lib.node: __snprintf_chk: symbol not found
    at Object.Module._extensions..node (module.js:598:18)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

I guess my base image and the alpine one use a different stdlib or something like that?

Most helpful comment

Any idea how I can build it instead of downloading the file located at https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v51-linux-x64.tar.gz?
I am using an Alpine image too.
Thanks

Edit: Got it from their documentation. If you're using bcrypt, run the following command:
npm rebuild bcrypt --build-from-source

All 5 comments

Correct, different libc (musl vs. glibc.)

Yeah, you ideally want to use the same base node level for both images.

Any idea how I can build it instead of downloading the file located at https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v51-linux-x64.tar.gz?
I am using an Alpine image too.
Thanks

Edit: Got it from their documentation. If you're using bcrypt, run the following command:
npm rebuild bcrypt --build-from-source

For all those you didn't get it to work after adding --build-from-source=bcrypt (or equivalent rebuild command after install) - make sure you're not copying your local node_modules into the image by adding .dockerignore file with contents:

node_modules/

I came here after updating node from 10 to 12. I received

Error: Error relocating /home/node/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: _ZN2v820EscapableHandleScope6EscapeEPPNS_8internal6ObjectE: symbol not found

In order to use node 12 you need to have bcrypt at least at 3.0.6
see https://www.npmjs.com/package/bcrypt#version-compatibility

Was this page helpful?
0 / 5 - 0 ratings