Error installing xml2json using node.js

I tried installing the xml2json package for node.js, but it gives me an error.

Error: enter image description here

My system configuration is shown below:

node.js version - v5.4.1

version for npm - 3.3.12

Operating System - Windows 10 64 bit

python - 2.7.11 (set as an environment variable)

After installing Microsoft sdk v7.1 windows, it causes an error below.

enter image description here

After adding package.json below is the error.

enter image description here

+5
source share
3 answers

You must explicitly specify the platform toolkit when creating with msbuild (called by node-gyp rebuild ). Try the command below before running npm :

 call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64 

See the meaning of the arguments below: SetEnv.cmd Usage :

/ Release - create a release configuration build environment

/ x64 - Create 64-bit x64 applications

Additional explanation

npm install xml2json must use the Windows SDK under the hood to create projects when installing packages with MSBuild . You are faced with a situation where your Windows SDK configuration is not compatible with node requirements.

Setting up the Windows SDK command prompt window :

If you do not have Visual Studio 2010, you can use the Windows SDK command prompt window and SetEnv utility to configure your application build settings.

So my suggestion is to use the SetEnv utility to fix your problem ...

Other ways to fix the problem

MSBuild uses the VCTargetsPath property, which cannot be found because this registry key is missing.

Check if the key exists and points to the correct path

  • Run regedit Navigator for HKLM \ SOFTWARE \ Microsoft \ MSBuild \ ToolsVersions \ WinSDKVersion
  • Check the VCTargetsPath key. The value should be "$ (MSBuildExtensionsPath64) \ Microsoft.Cpp \ WinSDKVersion \"

If the key does not exist or has the wrong value, correct the problem using the steps below:

  • Run regedit Navigator for HKLM \ SOFTWARE \ Microsoft \ MSBuild \ ToolsVersions \ WinSDKVersion
  • Add string key VCTargetsPath .
  • Set the value to "$ (MSBuildExtensionsPath64) \ Microsoft.Cpp \ WinSDKVersion \"

WinSDKVersion == v4.0 (this seems to be the value of your version of WinSDK), so replace WinSDKVersion with v4.0 .

+2
source

I believe that you need to set the environment variable VCTargetsPath.

Look at the answers to this question , there are several different approaches.

Installing it from the command line, doing something like this is probably the easiest way:

 set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120" 

The exact path will depend on the version of Visual Studio that you installed.

+1
source

You have to change your code a bit
Instead of installing xml2json, install xml-js
npm install --save xml-js

and then use this code to convert your xml file to json

 let convert = require('xml-js'); let xml = require('fs').readFileSync('./testscenario.xml', 'utf8'); let result = convert.xml2json(xml, {compact: true, spaces: 4}); console.log(result); 

It will work

0
source

Source: https://habr.com/ru/post/1241100/


All Articles