Keval Trivedi
Keval Trivedi

Reputation: 1300

Error while installing xml2json using node.js

I tried to install xml2json package for node.js but it gives me error.

Error are as below :enter image description here

My system configuration are as below :

node.js version - v5.4.1

npm version - 3.3.12

Operating system - windows 10 64 bit

python - 2.7.11(set as environment variable )

After installing microsoft windows sdk v7.1 it gives me below error.

enter image description here

After added package.json below error is given.

enter image description here

Upvotes: 6

Views: 2683

Answers (3)

Kunal Tyagi
Kunal Tyagi

Reputation: 4187

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

Upvotes: 1

Andriy Ivaneyko
Andriy Ivaneyko

Reputation: 22041

You have to explicitly specify the Platform Toolset when building with msbuild ( triggered by node-gyp rebuild) . Try command below, prior running npm:

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

See meaning of passed arguments below, from SetEnv.cmd Usage:

/Release - Create a Release configuration build environment

/x64 - Create 64-bit x64 applications

Additional explanations

npm install xml2json require using Windows SDK under the hood to build projects, while installing packages, with MSBuild. You have faced situation that your Windows SDK configuration isn't compatible with required by node.

Configuring the Windows SDK Command Prompt Window section:

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

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

Other ways to fix problem

MSBuild uses VCTargetsPath property, which cannot be located because the registry lacks this key.

Check whether key exists and points to proper path

  1. Launch regedit Navigator to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\WinSDKVersion
  2. Inspect VCTargetsPath key. The value should be "$(MSBuildExtensionsPath64)\Microsoft.Cpp\WinSDKVersion\"

if key doesn't exists or has wrong value, fix problem with steps below:

  1. Launch regedit Navigator to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\WinSDKVersion
  2. Add string key VCTargetsPath key
  3. Set Value to "$(MSBuildExtensionsPath64)\Microsoft.Cpp\WinSDKVersion\"

WinSDKVersion == v4.0 (Looks like that's value of Your WinSDK Version), so replace WinSDKVersion to v4.0.

Upvotes: 2

sheltond
sheltond

Reputation: 1937

I believe you need to set the VCTargetsPath environment variable.

Have a look at the answers to this question, there are a couple of different approaches.

Setting it from the command-line by doing something like this is probably the easiest approach:

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 have installed.

Upvotes: 1

Related Questions