我无法安装xml2json。我提到了许多其他帖子但没有任何效果。每次运行npm install xml2json
时都会出错请帮助并提供xml到json的任何工作示例
C:\employee>npm install xml2json
> node-expat@2.3.15 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
employee@0.0.0 C:\employee
`-- UNMET PEER DEPENDENCY typescript@2.0.10
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 fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/tsc-wrapped@4.0.2 requires a peer of typescript@^2.1.5 but none was installed.
npm WARN tsickle@0.21.6 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! node-expat@2.3.15 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.15 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
答案 0 :(得分:1)
你需要先安装python 2。
答案 1 :(得分: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。
答案 2 :(得分:0)
在安装Python之后,您需要设置一个名为PYTHON
的系统环境变量,该变量指向Python安装文件夹。然后,您将需要重新开始bash / powershell / command会话并安装xml2json。