我正在尝试为nodejs应用程序构建一个docker镜像。 Dockerfile:https://backstage.io/docs/deployment/docker#multi-stage-build
我的 Docker 构建命令失败,如下所示:
$ docker image build -t backstage .
...
...
...
9.056 warning Error running install script for optional dependency: "/app/node_modules/cpu-features: Command failed.
9.056 Exit code: 127
9.056 Command: node buildcheck.js > buildcheck.gypi && node-gyp rebuild
9.056 Arguments:
9.056 Directory: /app/node_modules/cpu-features
9.056 Output:
9.056 /bin/sh: 1: node-gyp: not found"
但是,我确实安装了
node-gyp
:
$ which node-gyp
/Users/<USERNAME>/.nvm/versions/node/v18.17.1/bin/node-gyp
还有:
$ npm ls -g
/Users/dheeraj.kabra/.nvm/versions/node/v18.17.1/lib
├── cor[email protected]
├── [email protected]
├── [email protected]
└── [email protected]
问题: 所以我不确定为什么 docker 构建过程会抱怨
node-gyp
not find.
我的 ENV 详细信息:
当我收到此错误时,此命令对我有用:
npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"