node.jsdockerubuntunode-modules

Error: libnode.so.64: cannot open shared object file: No such file or directory - Docker container


I created a docker container on ubuntu with following packages: default-jdk, node.js, curl, git, npm, python, make, gcc.

I'm trying to run this tool https://github.com/oasis-tcs/odata-openapi/tree/master/tools inside the container. All required dependencies (like node-gyp) have been installed and the tool itself can be installed using npm without any errors, just as described in the readme.

However, when trying to execute a command I always get this error:

Error: libnode.so.64: cannot open shared object file: No such file or directory
        at Object.Module._extensions..node (internal/modules/cjs/loader.js:1025:18)
        at Module.load (internal/modules/cjs/loader.js:815:32)
        at Function.Module._load (internal/modules/cjs/loader.js:727:14)
        at Module.require (internal/modules/cjs/loader.js:852:19)
        at require (internal/modules/cjs/helpers.js:74:18)
        at Object.<anonymous> (/odata-openapi/tools/node_modules/java/lib/nodeJavaBridge.js:21:16)
        at Module._compile (internal/modules/cjs/loader.js:959:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
        at Module.load (internal/modules/cjs/loader.js:815:32)
        at Function.Module._load (internal/modules/cjs/loader.js:727:14)

So far, I tried reinstalling node.js, node-gyp, installing packages like node-libs and different Ubuntu versions. The tool works fine on the host system.

Does anyone know how to handle this?


Solution

  • I suspect you have a mismatch installation with nodejs.

    It is important you make npm i after having installed the right version of nodejs.

    On a host, this arises when nodejs has been upgraded after npm i. In this case do:

    npm clean-install

    And voila.

    For your specific docker use case: You should make sure you installed nodejs AND did npm i from within the container, typically with RUN commands in your Dockerfile. This way you never have mismatches.

    BUT, this arises if you install nodejs on the host and shared the volume to your container: avoid this and turn to what I was mentioning previously.