我已经建立了一个 Gitlab CI 管道,它在第一阶段编译本机 Nodejs 插件,并在第二阶段使用它运行一些测试。
该作业在同一个 Docker 映像上运行:
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 映像上运行,但在运行测试时收到以下错误消息:
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 提供所需的目标也不会改变这一点:
node-gyp configure --target=$(node --version)
node-gyp build --target=$(node --version)
降级nodejs版本使错误消失:
在 Dockerfile 中:
RUN n 8.15.0
如何针对 Nodejs 的 LTS 版本(当前为 10.15.1)编译我的本机插件
也许编译未完成,因为现有模块。尝试使用重建,然后清理旧模块。
node-gyp configure --target=$(node --version)
node-gyp rebuild
node-gyp clean
希望这有帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)