【问题标题】:How to fix compiling error of a npm package used by a Meteor package when starting a Meteor app?如何修复启动 Meteor 应用程序时 Meteor 包使用的 npm 包的编译错误?
【发布时间】:2017-01-01 10:29:00
【问题描述】:

Meteor 应用程序 myapp 使用 Meteor 包 mypackage,它使用 npm 包 pingan-payment

当我用meteor 启动“myapp”时,mypackage 会尝试编译pingan-payment。但是在编译它的一个依赖项libxmljs时失败了:

$ meteor
[[[[[ ~/temp/myapp ]]]]]  

=> Started proxy.                             
myorg:mypackage: updating npm dependencies -- pingan-payment, dateformat, request, urllib...
=> Errors prevented startup:                  

   While building package myorg:mypackage:
   error: couldn't install npm packages from npm-shrinkwrap: Command failed: npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No
   description
   npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No repository field.
   npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No README data
   ../vendor/libxml/encoding.c: In function ‘xmlCharEncCloseFunc’:
   ../vendor/libxml/encoding.c:2856:12: warning: variable ‘handler_in_list’ set but not used [-Wunused-but-set-variable]
   int i, handler_in_list = 0;
   ^
   In file included from ../vendor/libxml/xpath.c:462:0:
   ../vendor/libxml/timsort.h: In function ‘libxml_domnode_tim_sort_collapse’:
   ../vendor/libxml/timsort.h:405:65: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
   ^
   ../vendor/libxml/timsort.h:397:19: warning: variable ‘BD’ set but not used [-Wunused-but-set-variable]
   int ABC, BCD, BD, CD;
   ^
   ../vendor/libxml/xpath.c: In function ‘xmlXPathNodeCollectAndTest’:
   ../vendor/libxml/xpath.c:12406:28: warning: comparison between ‘xmlElementType {aka enum <anonymous>}’ and ‘xmlXPathTypeVal {aka enum <anonymous>}’
   [-Wenum-compare]
   } else if (cur->type == type) {
   ^
   In file included from ../vendor/libxml/xpath.c:476:0:
   ../vendor/libxml/xpath.c: At top level:
   ../vendor/libxml/trionan.c:194:1: warning: ‘trio_is_special_quantity’ defined but not used [-Wunused-function]
   trio_is_special_quantity
   ^
   ../vendor/libxml/trionan.c:218:1: warning: ‘trio_is_negative’ defined but not used [-Wunused-function]
   trio_is_negative
   ^
   ../vendor/libxml/xpointer.c: In function ‘xmlXPtrNewRangeNodePoint’:
   ../vendor/libxml/xpointer.c:451:21: warning: comparison between ‘xmlElementType {aka enum <anonymous>}’ and ‘enum <anonymous>’
   [-Wenum-compare]
   if (start->type != XPATH_POINT)
   ^
   ../src/libxmljs.cc:3:16: fatal error: v8.h: No such file or directory
   compilation terminated.
   make: *** [Release/obj.target/xmljs/src/libxmljs.o] Error 1
   gyp ERR! build error 
   gyp ERR! stack Error: `make` failed with exit code: 2
   gyp ERR! stack     at ChildProcess.onExit
   (/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/n$
de_modules/node-gyp/lib/build.js:267:23)
   gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
   gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
   gyp ERR! System Linux 4.4.0-31-generic
   gyp ERR! command "node"
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/n$
de_modules/node-gyp/bin/node-gyp.js"
   "rebuild"
   gyp ERR! cwd
   /home/leo/temp/myapp/packages/mypackage/.npm/package-new-zx4ald/node_modules/pingan-payment/node_modules/libxmljs
   gyp ERR! node -v v0.10.40
   gyp ERR! node-gyp -v v1.0.1
   gyp ERR! not ok 

   npm ERR! libxmljs@0.18.0 install: `node-gyp rebuild`
   npm ERR! Exit status 1
   npm ERR! 
   npm ERR! Failed at the libxmljs@0.18.0 install script.
   npm ERR! This is most likely a problem with the libxmljs package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     node-gyp rebuild
   npm ERR! You can get their info via:
   npm ERR!     npm owner ls libxmljs
   npm ERR! There is likely additional logging output above.
   npm ERR! System Linux 4.4.0-31-generic
   npm ERR! command
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node"
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm" "install"
   npm ERR! cwd /home/leo/temp/myapp/packages/mypackage/.npm/package-new-zx4ald
   npm ERR! node -v v0.10.40
   npm ERR! npm -v 1.4.28
   npm ERR! code ELIFECYCLE
   npm ERR! not ok code 0
   npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No description
   npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No repository field.
   npm WARN package.json packages-for-meteor-smartpackage-16ai9vy@0.0.0 No README data
   ../vendor/libxml/encoding.c: In function ‘xmlCharEncCloseFunc’:
   ../vendor/libxml/encoding.c:2856:12: warning: variable ‘handler_in_list’ set but not used [-Wunused-but-set-variable]
   int i, handler_in_list = 0;
   ^
   In file included from ../vendor/libxml/xpath.c:462:0:
   ../vendor/libxml/timsort.h: In function ‘libxml_domnode_tim_sort_collapse’:
   ../vendor/libxml/timsort.h:405:65: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
   ^
   ../vendor/libxml/timsort.h:397:19: warning: variable ‘BD’ set but not used [-Wunused-but-set-variable]
   int ABC, BCD, BD, CD;
   ^
   ../vendor/libxml/xpath.c: In function ‘xmlXPathNodeCollectAndTest’:
   ../vendor/libxml/xpath.c:12406:28: warning: comparison between ‘xmlElementType {aka enum <anonymous>}’ and ‘xmlXPathTypeVal {aka enum <anonymous>}’
   [-Wenum-compare]
   } else if (cur->type == type) {
   ^
   In file included from ../vendor/libxml/xpath.c:476:0:
   ../vendor/libxml/xpath.c: At top level:
   ../vendor/libxml/trionan.c:194:1: warning: ‘trio_is_special_quantity’ defined but not used [-Wunused-function]
   trio_is_special_quantity
   ^
   ../vendor/libxml/trionan.c:218:1: warning: ‘trio_is_negative’ defined but not used [-Wunused-function]
   trio_is_negative
   ^
   ../vendor/libxml/xpointer.c: In function ‘xmlXPtrNewRangeNodePoint’:
   ../vendor/libxml/xpointer.c:451:21: warning: comparison between ‘xmlElementType {aka enum <anonymous>}’ and ‘enum <anonymous>’
   [-Wenum-compare]
   if (start->type != XPATH_POINT)
   ^
   ../src/libxmljs.cc:3:16: fatal error: v8.h: No such file or directory
   compilation terminated.
   make: *** [Release/obj.target/xmljs/src/libxmljs.o] Error 1
   gyp ERR! build error 
   gyp ERR! stack Error: `make` failed with exit code: 2
   gyp ERR! stack     at ChildProcess.onExit
   (/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/no
de_modules/node-gyp/lib/build.js:267:23)
   gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
   gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
   gyp ERR! System Linux 4.4.0-31-generic
   gyp ERR! command "node"
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/no
de_modules/node-gyp/bin/node-gyp.js"
   "rebuild"
   gyp ERR! cwd
   /home/leo/temp/myapp/packages/mypackage/.npm/package-new-zx4ald/node_modules/pingan-payment/node_modules/libxmljs
   gyp ERR! node -v v0.10.40
   gyp ERR! node-gyp -v v1.0.1
   gyp ERR! not ok 

   npm ERR! libxmljs@0.18.0 install: `node-gyp rebuild`
   npm ERR! Exit status 1
   npm ERR! 
   npm ERR! Failed at the libxmljs@0.18.0 install script.
   npm ERR! This is most likely a problem with the libxmljs package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     node-gyp rebuild
   npm ERR! You can get their info via:
   npm ERR!     npm owner ls libxmljs
   npm ERR! There is likely additional logging output above.
   npm ERR! System Linux 4.4.0-31-generic
   npm ERR! command
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node"
   "/home/leo/.meteor/packages/meteor-tool/.1.1.9.30iceu++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/npm" "install"
   npm ERR! cwd /home/leo/temp/myapp/packages/mypackage/.npm/package-new-zx4ald
   npm ERR! node -v v0.10.40
   npm ERR! npm -v 1.4.28
   npm ERR! code ELIFECYCLE
   npm ERR! not ok code 0


=> Your application has errors. Waiting for file change.

我在上面的错误消息中搜索~/temp/myapp~/.meteor 文件../vendor/libxml/encoding.c,但没有。

如何调试和修复错误?

【问题讨论】:

    标签: meteor compilation npm package


    【解决方案1】:

    您的错误转储显示您使用的是旧版本的 meteor-tool 软件包。您应该考虑将 Meteor (meteor update) 更新到更新的版本,因为最近有一个 number of improvements 专门围绕 node-gyp 集成。

    【讨论】:

    • 是的,我尝试更新,但我得到了this error
    【解决方案2】:

    libxmljs 编译libxml 时缺少系统包。当您使用 vanilla 操作系统时,通常会发生此特定错误。

    请尝试以下命令:

    apt-get install libxml2-dev
    

    【讨论】:

      【解决方案3】:

      你需要安装 apt-get install g++ libtool libxml2-dev libxml2

      【讨论】:

        【解决方案4】:

        我昨天遇到了同样的v8.h: No such file or directory 错误,原因可能是我使用 nvm 运行节点 v6.x 但系统的节点是 v0.10 和 libxmljs 有点使用错误的 node-gyp 来编译它的代码。所以在我根据https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04更新系统节点到v6.x后,模块编译正确。

        【讨论】:

          猜你喜欢
          • 2013-05-24
          • 2015-06-12
          • 2018-05-26
          • 2015-01-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-03-13
          • 2017-05-01
          相关资源
          最近更新 更多