Javascript 错误:找不到模块';xml2json';

Javascript 错误:找不到模块';xml2json';,javascript,node.js,npm,npm-install,libxml-js,Javascript,Node.js,Npm,Npm Install,Libxml Js,当运行我的项目包时,在我尝试使用安装该包之后,出现了上面的标题错误 npm安装xml2json 但是,我只有下面的错误,你能给我一些建议或想法来摆脱这个问题 D:\xampp\htdocs\podio>npm install xml2json > node-expat@2.3.16 install D:\xampp\htdocs\podio\node_modules\node-expat > node-gyp rebuild D:\xampp\htdocs\podio\n

当运行我的项目包时,在我尝试使用安装该包之后,出现了上面的标题错误

npm安装xml2json

但是,我只有下面的错误,你能给我一些建议或想法来摆脱这个问题

D:\xampp\htdocs\podio>npm install xml2json

> node-expat@2.3.16 install D:\xampp\htdocs\podio\node_modules\node-expat
> node-gyp rebuild


D:\xampp\htdocs\podio\node_modules\node-expat>if not defined npm_config_node_gyp
 (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Warning: Missing input files:
D:\xampp\htdocs\podio\node_modules\node-expat\build\deps\libexpat\..\..\..\deps\
libexpat\version.c
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
 To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere.  [D:\xampp\htdocs\podio\node_modules\node-expat\build\b
inding.sln]
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:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:219:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\xampp\htdocs\podio\node_modules\node-expat
gyp ERR! node -v v6.11.5
gyp ERR! node-gyp -v v3.4.0
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"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! node-expat@2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.16 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\xampp\htdocs\podio\npm-debug.log
编辑::1

在我安装了更新的visual studio 2005至2012之后,当我运行npm install xml2json和npm install xml2json--unsafe perm时,我发现以下错误:

C:\Users\Desktop\New folder\action>npm install xml2json

> node-expat@2.3.16 install C:\Users\Hoffensoft\node_modules\node-expat
> node-gyp rebuild


C:\Users\Hoffensoft\node_modules\node-expat>if not defined npm_config_node_gyp (
node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modu
les\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Warning: Missing input files:
C:\Users\Hoffensoft\node_modules\node-expat\build\deps\libexpat\..\..\..\deps\li
bexpat\version.c
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
c:\users\hoffensoft\node_modules\node-expat\deps\libexpat\lib\siphash.h(201): w
arning C4244: 'initializing' : conversion from '__int64' to 'char', possible lo
ss of data (..\..\..\deps\libexpat\lib\xmlparse.c) [C:\Users\Hoffensoft\node_mo
dules\node-expat\build\deps\libexpat\expat.vcxproj]
  win_delay_load_hook.cc
  expat.vcxproj -> C:\Users\Hoffensoft\node_modules\node-expat\build\Release\\l
  ibexpat.lib
  node-expat.cc
  win_delay_load_hook.cc
C:\Users\Hoffensoft\node_modules\nan\nan.h(75): fatal error C1060: compiler is
out of heap space (..\node-expat.cc) [C:\Users\Hoffensoft\node_modules\node-exp
at\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:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:219:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Hoffensoft\node_modules\node-expat
gyp ERR! node -v v6.11.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Hoffensoft\pac
kage.json'
npm WARN Hoffensoft No description
npm WARN Hoffensoft No repository field.
npm WARN Hoffensoft No README data
npm WARN Hoffensoft No license field.
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"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! node-expat@2.3.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.16 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Hoffensoft\Desktop\New folder\action\npm-debug.log

提前谢谢,Gopal R

我已经解决了这个问题。如果您注意到命令的这一部分,我认为发生的情况是,如果未将npm\u config\u node\u gyp定义为
false
,则错误地将
计算为
false
,并尝试不运行任何内容而不是运行node gyp。您需要做的是定义
npm\u config\u node\u gyp
变量。您可以这样做:
export npm\u config\u node\u gyp=
请记住,Windows需要双反斜杠。对我来说,它看起来像这样:
export npm\u config\u node\u gyp=C:\\Users\\781990\\AppData\\Roaming\\nvm\\v6.11.0\\node\u modules\\node gyp

编辑: 在我修复之后还有一步。在执行我的代码时,expat绑定丢失。要修复此问题,请将bin文件夹和节点gyp可执行文件添加到
npm\u config\u node\u gyp
变量中,并在
node\u modules\node expat
文件夹中运行
node gyp rebuild
。例如
export npm\u config\u node\u gyp=C:\\Users\\781990\\AppData\\Roaming\\nvm\\v6.11.0\\node\u modules\\node gyp\\bin\\node gyp.js
cd节点\u模块\node expat
节点gyp重建

我已经解决了这个问题
使用此命令
npm安装xml2json light

并更改
let parser=require('xml2json')
to
let parser=require('xml2json-light')

这对我来说很有效

从“要修复此问题,1)安装…”行开始的错误中写入了一些建议。您尝试过这些建议了吗?npm是否安装xml2json--saveyes@ArpitSolanki,我尝试过了我已经安装但仍然不工作否@MohammadRaheem也有同样的错误,--save只是将名称保存在package.json文件中。您使用的是Angular 2/4吗?