Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 919
mxcd Avatar asked Feb 07 '19 03:02

mxcd


People also ask

What version of python do I need for node Gyp?

You’ll have to run this command: npm config set msvs_version 2015 –global 5. Make sure you have Python 2.7 installed. Next up is to download Python 2.7. This is important–by default, you’ll install the newest version (3.x.x), but only 2.7 is compatible with node-gyp.

What is node-Gyp in NPM?

node-gyp is a tool that enables the compilation of native add-on modules for Node in multiple platforms. It has widespread use and is included as a dependency in many NPM packages. On most systems, this isn’t an issue, and installing node-gyp with the rest of your packages works as expected.

What version of Visual Studio does node-Gyp require?

However, node-gyp requires the v140 distributable, not the v150 (which comes with VS2017). This is why the --vs2015 flag is added to the end of the command, since that’s the last version of Visual Studio that came with the v140 package.

How to fix node-Gyp issues on Windows?

A Comprehensive Guide to Fixing Node-Gyp Issues on Windows 1. Try running npm install with the --no-optional flag.. If you’re lucky, the dependency that requires node-gyp will be... 2. Try downloading the windows-build-tools package.. According to the node-gyp documentation, this step should be ...


1 Answers

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

like image 85
Ulises Avatar answered Sep 24 '22 09:09

Ulises