简体   繁体   English

npm install xml2json错误

[英]npm install xml2json error

getting error while running npm install xml2json in windows cmd 在Windows cmd中运行npm install xml2json时出错

resolved python & .net dependency but stuck in "fatal error C1060: compiler is out of heap space" 已解决python和.net依赖但卡在“致命错误C1060:编译器已超出堆空间”

cannot install in any node js project throughout my windows system 无法在我的Windows系统中的任何节点js项目中安装

npm install simple-xml2json & parallel-xml2json are working fine

>npm install xml2json --save request
npm WARN package.json @ No description
npm WARN package.json @ No repository field.
npm WARN package.json @ No README data
npm WARN package.json @ No license field.
-
> node-expat@2.3.13 install xxxxxxxxxxxxxxxxxxxxxxxxxxx\xml2json\node_modules\node-expat
> node-gyp rebuild


xxxxxxxxxxxxxxxxxxxxx\xml2json\node_modules\node-expat>if not defined npm_config_node_gyp (node "C:\Program Files\nodej
s\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  xmlparse.c
  xmltok.c
  xmlrole.c
  win_delay_load_hook.c
..\..\..\deps\libexpat\lib\xmlparse.c(1844): warning C4244: 'return' : conversion from '__int64' to 'XML_Index', possible loss of data [xxxxxxxxxxxx\xml2json\node_modules\node-expat\build\deps\libexpat\expat.vcxproj]
  expat.vcxproj -> xxxxxxxxxxxxxxxx\xml2json\node_modules\node-expat\build\Release\\libexpat.lib
  node-expat.cc
xxxxxxxxxxxxxxxxxx\xml2json\node_modules\node-expat\node_modules\nan\nan.h(72): fatal error C1060: compiler is out
of heap space [xxxxxxxxxxxxxxxxxxxxxxxxxx\xml2json\node_modules\node-expat\build\node_expat.vcxproj]
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 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebui
ld"
gyp ERR! cwd xxxxxxxxxxxxxxxxxxxxxxxxxxxxxs\xml2json\node_modules\node-expat
gyp ERR! node -v v4.4.3
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "xml2json" "--save" "req
uest"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! node-expat@2.3.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.13 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-expat 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 information on how to open an issue for this project               >with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

Some libraries which are based on C/C++ based libraries require to install additional libraries on an OS. 一些基于C / C ++库的库需要在OS上安装其他库。 Sometimes even yarn need extra permissions to add such libraries. 有时甚至yarn需要额外的权限来添加这样的库。

Follow this guide to install extra dependencies. 请按照指南安装额外的依赖项。 Or use some other XML to JS/JSON parser library, like fast-xml-parser which is purely based JS regx. 或者使用其他一些XML到JS / JSON解析器库,比如基于JS regx的fast-xml-parser

I have solved this. 我解决了这个问题。 If you notice this part of the command else (node "" rebuild ) what I think is happening is that it is incorrectly evaluating if not defined npm_config_node_gyp as false and trying to run nothing instead of node-gyp. 如果您注意到命令else (node "" rebuild ) if not defined npm_config_node_gyp部分else (node "" rebuild ) ,我认为正在发生的是, if not defined npm_config_node_gypfalse并且尝试不运行任何而不是node- if not defined npm_config_node_gyp ,则会错误地进行评估。 What you need to do is define your npm_config_node_gyp variable. 您需要做的是定义您的npm_config_node_gyp变量。 You can do this like so: export npm_config_node_gyp=<PATH_TO_NODE_GYP_PACKAGE_FOLDER> remember that Windows will need double backslashes. 你可以这样做: export npm_config_node_gyp=<PATH_TO_NODE_GYP_PACKAGE_FOLDER>记住Windows需要双反斜杠。 For me, it looked like this: export npm_config_node_gyp=C:\\\\Users\\\\781990\\\\AppData\\\\Roaming\\\\nvm\\\\v6.11.0\\\\node_modules\\\\node-gyp 对我来说,它看起来像这样: export npm_config_node_gyp=C:\\\\Users\\\\781990\\\\AppData\\\\Roaming\\\\nvm\\\\v6.11.0\\\\node_modules\\\\node-gyp

Edit: There is another step after my fix. 编辑:修复后还有另一步。 When executing my code, the expat bindings were missing. 执行我的代码时,缺少expat绑定。 To fix it, add the bin folder and node-gyp executable to the npm_config_node_gyp variable and run node-gyp rebuild in the node_modules\\node-expat folder. 要修复它,请将bin文件夹和node- npm_config_node_gyp可执行文件添加到npm_config_node_gyp变量,并在node_modules\\node-expat文件夹中运行node-gyp rebuild node_modules\\node-expat node-gyp rebuild eg export npm_config_node_gyp=C:\\\\Users\\\\781990\\\\AppData\\\\Roaming\\\\nvm\\\\v6.11.0\\\\node_modules\\\\node-gyp\\\\bin\\\\node-gyp.js cd node_modules\\node-expat node-gyp rebuild 例如export npm_config_node_gyp=C:\\\\Users\\\\781990\\\\AppData\\\\Roaming\\\\nvm\\\\v6.11.0\\\\node_modules\\\\node-gyp\\\\bin\\\\node-gyp.js cd node_modules\\node-expat node-gyp rebuild

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM