mxcd
mxcd

Reputation: 2414

node-gyp compiling against wrong NODE_MODULE_VERSION

I've set up a Gitlab CI pipeline which is compiling a native nodejs addon in the first stage and running some tests with it in the second one. The job is running on the same Docker image:

FROM ubuntu:18.04
RUN apt update
RUN apt install -y git cmake gcc build-essential nodejs npm curl
RUN npm i -g n
RUN n latest
RUN npm i -g node-gyp
RUN npm i -g yarn

Although the both stages are running on the same docker image, I get the following error message when running the test:

Error: The module '<path_to_module>'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 57.

Even giving node-gyp the desired target in form of the current nodejs version doesn't change this:

node-gyp configure --target=$(node --version)
node-gyp build --target=$(node --version)

Downgrading the nodejs version makes the error disappear:
In the Dockerfile:

RUN n 8.15.0

How can I compile my native addon against the LTS version of nodejs (currently 10.15.1)

Upvotes: 14

Views: 2477

Answers (1)

Ulises
Ulises

Reputation: 549

Maybe compilation is not done because an existing module. Try using rebuild and then clean for the old modules.

node-gyp configure --target=$(node --version)
node-gyp rebuild
node-gyp clean

hope this help

Upvotes: 2

Related Questions