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)
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.
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.
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.
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 ...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With