Search code examples
linuxnode.jsbcryptopenshift-cartridge

bcrypt error after upgrading nodejs gear to v0.12 on Openshift


After upgrading the nodejs version running on my Openshift's gear from v0.10 to v0.12, I get the following error:

Error: /app-root/runtime/repo/node_modules/bcrypt/build/Release/bcrypt_lib.node: undefined     
symbol: node_module_register    
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at bindings (/app-root/runtime/repo/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/app-root/runtime/repo/node_modules/bcrypt/bcrypt.js:3:35)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

The bcrypt version in my package.json is set to ~0.8.5.

So far I have tried these without success:
- rhc ssh myapp then update node-gyp, rm -rf node_modules and npm install;
- manually installed the dependencies;
- edited package.json to preinstall node-gyp

"scripts":{
    "preinstall": "npm i -g node-gyp && node-gyp clean"
}

anyone has an idea / knows on how I can solve this? (ideally the solution won't require to upgrade gcc)

Also, I am using Ryan J's custom cartridge for nodejs v.012


Solution

  • I finally solved it with a workaround by editing .openshift\lib\utils and adding export OPENSHIFT_NODEJS_VERSION=0.6 in the setup_path_for_custom_node_version() function:

    #  Add the node binary path to the PATH.
    export OPENSHIFT_NODEJS_VERSION=0.6
    export PATH="$node_bin_path:${PATH}"