簡體   English   中英

節點gyp重建失敗高山linux xxhash package

[英]node-gyp rebuild fail alpine linux xxhash package

我以前沒有遇到過這個問題,我有 nodegyp (g++ make python) 的所有先決條件,它在 alpine 3.13 上工作。 但是一旦 node:14-alpine 更新到最新的 alpine,它就會在構建過程中開始失敗。

tldr:構建適用於 alpine 3.13 但不適用於 3.14 - nodegyp 問題

Docker版本:Docker版本20.10.11,build dea9396

集裝箱集裝箱d.io 1.4.12 7b11cfaabd73bb80907dd23182b9347b4245eb5d

Dockerfile:

FROM node:14-alpine as builder

RUN mkdir /app && chown node:node /app && npm i npm@latest -g
WORKDIR /app

COPY package*.json .npmrc ./
RUN apk add --no-cache --virtual .gyp python3 make g++ \
    && npm ci --only=production && npm cache clean --force \
    && apk del .gyp \
        && rm -f .npmrc

ENV PATH /app/node_modules/.bin:$PATH
COPY --chown=node:node . .

FROM builder as dev
WORKDIR /app
RUN npm ci
ENV PATH /app/node_modules/.bin:$PATH
USER node
CMD ["nodemon", "index.js"]


完整的錯誤是:

npm ERR! path /app/node_modules/xxhash
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/app/node_modules/xxhash/build'
npm ERR! make: Leaving directory '/app/node_modules/xxhash/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@14.18.2 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3"
npm ERR! gyp WARN EACCES current user ("node") does not have permission to access the dev dir "/root/.cache/node-gyp/14.18.2"
npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v14.18.2/node-v14.18.2-headers.tar.gz
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v14.18.2/node-v14.18.2-headers.tar.gz
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v14.18.2/SHASUMS256.txt
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v14.18.2/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/app/node_modules/xxhash/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/tmp/.node-gyp/14.18.2/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/tmp/.node-gyp/14.18.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/tmp/.node-gyp/14.18.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/app/node_modules/xxhash',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [hash.target.mk:117: Release/obj.target/hash/src/hash.o] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
npm ERR! gyp ERR! System Linux 5.4.0-1057-aws
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /app/node_modules/xxhash
npm ERR! gyp ERR! node -v v14.18.2
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

搜索了一段時間后卡住並沒有找到解決方案

與 docker 圖像節點:16.3.1-alpine(使用 alpine 3.14)有同樣的問題。

您對 alpine 3.14 https://github.com/alpinelinux/docker-alpine/issues/178的問題似乎存在問題。

Alpine 3.15 應該已經修復了這個問題,但是節點 docker 映像尚未升級到 alpine 3.15。

通過將 alpine 版本降級到 3.13(節點:16.3.1-alpine3.13)解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM