首页 > 解决方案 > node-libxml-xsd 在进行 node-gyp 重建时失败,并显示“...xmljs.node:文件无法识别:文件格式无法识别”

问题描述

尝试为 Meteor 应用程序创建 Docker 容器时,尝试编译node-libxml-xsd时node-gyp 重建失败,并出现以下错误:

<command-line>:0:0: note: this is the location of the previous definition
  SOLINK_MODULE(target) Release/obj.target/node-libxml-xsd.node
/home/docker/data/app/programs/server/npm/node_modules/libxmljs-mt/build/Release/xmljs.node: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [Release/obj.target/node-libxml-xsd.node] Error 1
node-libxml-xsd.target.mk:133: recipe for target 'Release/obj.target/node-libxml-xsd.node' failed
make: Leaving directory '/home/docker/data/app/programs/server/npm/node_modules/libxml-xsd/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.9.93-boot2docker
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/docker/data/app/programs/server/npm/node_modules/libxml-xsd
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! libxml-xsd@0.5.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the libxml-xsd@0.5.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我正在使用 Node 8.9.4 在 Mac (boot2docker) 上构建它。有任何想法吗?

标签: node.jsdockermeteornode-gyp

解决方案


我找到了答案,所以我为后代发布:

原来 libxml-xsd 不会先重建 libxmljs-mt,所以在运行 npm install 之前,我需要运行:

cd npm && npm rebuild --unsafe-perm libxmljs-mt

推荐阅读