NPM安装错误 - node-gyp

4
尝试安装xml-stream包,但是构建依赖项时一直失败。它似乎需要vc2010(vcbuild.exe),但我已经安装了.Net Framework 2.0 SDK,其中包括vcbuild文件,而在安装xml-stream时我得到了以下错误:
> node-expat@2.0.0 install G:\Pessoal\node\bugzilla\node_modules\xml-stream\node
_modules\node-expat
> node-gyp rebuild


G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-expat>node "D
:\Bin\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\
node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
  The following error has occurred during XML parsing:

  File: G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-expa
  t\build\deps\libexpat\expat.vcproj
  Line: 1
  Column: 4916
VCBUILD : error Message:  [G:\Pessoal\node\bugzilla\node_modules\xml-stream\nod
e_modules\node-expat\build\binding.sln]
  Erro de sistema: -2147154687.

  The file 'G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-
  expat\build\deps\libexpat\expat.vcproj' has failed to load.
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\Bin\nodejs\node_modules\npm\node_m
odules\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:810:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "D:\\Bin\\nodejs\\node_modules\\npm\\node_modules\\node-
gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd G:\Pessoal\node\bugzilla\node_modules\xml-stream\node_modules\node-
expat
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
1个回答

1
我认为这是因为xml-stream依赖于node-expat,而node-expat又依赖于node-gyp。在Windows上,您需要安装VS2007或以其他方式安装node-gyp所需的正确SDK才能使用它。

在我的情况下,我不想跳过这些步骤,所以我发现使用sax编写一个非常简单的XML解析器并且没有依赖于node-gyp更容易。
我将其放在了NPM上:https://www.npmjs.com/package/no-gyp-xml-stream
或者只需运行:npm install no-gyp-xml-stream

它仍然是一个正在进行中的项目,但它可以工作,易于使用,并且允许您通过回调读取流返回的子元素。它唯一的依赖关系是sax,不需要安装任何东西。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接