Uzlopak
Uzlopak

Reputation: 342

Failing to build node-re2 on a node:12.18.1-alpine docker image

I try to get the node-re2 being build on latest node 12.18.1 lts alpine so that i can later copy the binary to the productive image. Unfortunately it fails to compile. What am I missing? Installing libc6-compat or gcompat with RUN apk add --no-cache gcompat or RUN apk add --no-cache libc6-compat does not help, even though the ld-linux-x86-64.so.2 file should be in the package.

My dockerfile is

FROM node:12.18.1-alpine as re2-builder

WORKDIR /opt

RUN apk add python make g++ \
    && npm install [email protected]

When building I get this:

Writing to build/Release/re2.node ...

> [email protected] verify-build /opt/node_modules/re2
> node scripts/verify-build.js

internal/modules/cjs/loader.js:1188
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /opt/node_modules/re2/build/Release/re2.node)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1188:18)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/opt/node_modules/re2/re2.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] verify-build: `node scripts/verify-build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] verify-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-19T21_07_53_335Z-debug.log
Building locally ...

> [email protected] rebuild /opt/node_modules/re2
> node-gyp rebuild
...

Upvotes: 4

Views: 4080

Answers (2)

Arpita Raj
Arpita Raj

Reputation: 1

**Cannot start the application. Error: The module '/home/user/Desktop/node_modules/email-reply-parser/node_modules/re2/build/Release/re2.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 108. This version of Node.js requires NODE_MODULE_VERSION 93. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). I got this error so the solution to solve this: for 108 we need to install 16th version of node js and for 109 need to install version 18 **

- Solution: I got this error so the solution to solve this: for 108 we need to install 16th version of node js and for 109 need to install version 18

  1. Run nvm install 16 and then nvm use 16

  2. run nvm install 18 and nvm use 18

  3. Run npm install

  4. npm start

Upvotes: 0

tinker
tinker

Reputation: 925

Alpine uses musl libc and its shared library loader name is ld-musl-x86_64.so.1 which resides in /lib directory. ld-linux-x86-64.so.2 is glibc shared library loader that's used in Ubuntu or other standard distros. There is compatibility layer package name libc6-compat try adding that.

apk add libc6-compat

Or try symlinking the original file

ln -s /lib/ld-musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 

That should solve.

Error loading shared library ld-linux-x86-64.so.2: No such file or directory

Upvotes: 3

Related Questions