针对错误的NODE_MODULE_VERSION的node-gyp编译 [英] node-gyp compiling against wrong NODE_MODULE_VERSION

查看:452
本文介绍了针对错误的NODE_MODULE_VERSION的node-gyp编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个Gitlab CI管道,该管道在第一阶段将编译本机nodejs插件,然后在第二阶段对其进行一些测试。
作业在同一Docker映像上运行:

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

尽管两个阶段都在同一个docker映像上运行,但我得到以下信息运行测试时出现错误消息:

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.

即使以当前nodejs版本的形式为node-gyp提供所需的目标,也不会改变这一点:

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)

降级nodejs版本会使错误消失:

在Dockerfile中:

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

RUN n 8.15.0

如何针对nodejs的LTS版本(当前为10.15.1)编译本机插件

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

推荐答案

也许是由于现有模块而未完成编译。尝试使用重建功能,然后清理旧模块。

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

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

希望获得帮助

这篇关于针对错误的NODE_MODULE_VERSION的node-gyp编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆