Angular2:无法安装xml2json

问题描述 投票:1回答:3

我无法安装xml2json。我提到了许多其他帖子但没有任何效果。每次运行npm install xml2json时都会出错

请帮助,并提供xml到json的任何工作示例

C:\employee>npm install xml2json

> [email protected] install C:\employee\node_modules\node-expat
> node-gyp rebuild


C:\employee\node_modules\node-expat>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:112:15)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\employee\node_modules\node-expat
gyp ERR! node -v v7.5.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
[email protected] C:\employee
`-- UNMET PEER DEPENDENCY [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/[email protected] requires a peer of typescript@^2.1.5 but none was installed.
npm WARN [email protected] requires a peer of typescript@^2.1.0 but none was installed.
npm ERR! Windows_NT 10.0.14393
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 v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:\employee\npm-debug.log

Expat error

angular
3个回答
1
投票

你需要先安装python 2。


0
投票

xml2json依赖于node-expat,它依赖于node-gyp,需要你安装Python 2.7 (not 3.6)

重要提示:检查installation instructions并根据您的操作系统执行相应步骤。

例如,在Windows上,您还需要以管理员身份运行npm install --global --production windows-build-tools,这样您就不会遇到MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe"

另外别忘了检查installation instructions for node-expat


0
投票

安装Python之后,您需要设置一个名为PYTHON的系统环境变量,该变量指向Python安装文件夹。然后,您将需要启动一个新的bash / powershell /命令会话并安装xml2json。

© www.soinside.com 2019 - 2024. All rights reserved.