M1 MacBook构建Node.js Docker容器报错求助
M1 MacBook构建Node.js Docker容器失败问题
简而言之:我的M1 MacBook无法构建Docker容器,但团队其他人都可以!
我是团队中唯一使用M1 MacBook的成员,在构建基于Node.js的Docker容器时遇到了诸多问题。
以下是我认为相关的Dockerfile关键内容:
FROM node:22.5-slim // ... RUN apt-get update \ && apt-get install -y tree git postgresql-client tini curl jq yq \ && npm i -g typescript // ... RUN yarn install
我遇到了多种不同的问题,以下是部分报错信息:
YN0000: │ secp256k1@npm:4.0.3 STDERR gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 33.91 ➤ YN0000: │ secp256k1@npm:4.0.3 STDERR gyp ERR! cwd /app/node_modules/secp256k1 33.91 ➤ YN0000: │ secp256k1@npm:4.0.3 STDERR gyp ERR! node -v v22.5.1 33.91 ➤ YN0000: │ secp256k1@npm:4.0.3 STDERR gyp ERR! node-gyp -v v10.1.0 33.91 ➤ YN0000: │ secp256k1@npm:4.0.3 STDERR gyp ERR! not ok
或
33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR SyntaxError: invalid syntax 33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! configure error 33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! stack Error: `gyp` failed with exit code: 1 33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! stack at ChildProcess.<anonymous> (/app/node_modules/node-gyp/lib/configure.js:297:18) 33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! stack at ChildProcess.emit (node:events:520:28) 33.70 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! System Linux 5.15.49-linuxkit-pr 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! cwd /app/node_modules/@parcel/watcher 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! node -v v22.5.1 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! node-gyp -v v10.1.0 33.71 ➤ YN0000: │ @parcel/watcher@npm:2.0.4 STDERR gyp ERR! not ok
或
50.41 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] 50.41 ➤ YN0000: │ node-hid@npm:2.1.1 STDOUT make: Entering directory '/app/vendor/cosmjs/node_modules/node-hid/build' 50.41 ➤ YN0000: │ node-hid@npm:2.1.1 STDOUT CC(target) Release/obj.target/hidapi/hidapi/libusb/hid.o 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR ../hidapi/libusb/hid.c:47:10: fatal error: libusb.h: No such file or directory 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR 47 | #include <libusb.h> 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR | ^~~~~~~~~~ 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR compilation terminated. 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR make: *** [hidapi.target.mk:106: Release/obj.target/hidapi/hidapi/libusb/hid.o] Error 1 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDOUT make: Leaving directory '/app/vendor/cosmjs/node_modules/node-hid/build' 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! build error 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! stack Error: `make` failed with exit code: 2 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! stack at ChildProcess.onExit (/app/vendor/cosmjs/node_modules/node-gyp/lib/build.js:203:23) 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! stack at ChildProcess.emit (node:events:520:28) 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! System Linux 5.15.49-linuxkit-pr 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! command "/usr/local/bin/node" "/app/vendor/cosmjs/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! cwd /app/vendor/cosmjs/node_modules/node-hid 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! node -v v22.5.1 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! node-gyp -v v9.4.0 50.44 ➤ YN0000: │ node-hid@npm:2.1.1 STDERR gyp ERR! not ok 50.45 ➤ YN0009: │ node-hid@npm:2.1.1 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-39a3cac7/build.log) 50.45 ➤ YN0000: └ Completed in 9s 985ms
内容的提问来源于stack exchange,提问作者Olshansky
相关产品推荐
相关产品推荐

