node-gyp compiling against wrong NODE_MODULE_VERSION

我的未来我决定 提交于 2019-12-06 20:59:45

问题


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)

来源:https://stackoverflow.com/questions/54565777/node-gyp-compiling-against-wrong-node-module-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!