Node packages not building on Windows 8.1 - Missing Microsoft.Cpp.Default.props
C++Visual Studio-2010node.jsVisual Studio-2012MsbuildC++ Problem Overview
NPM packages are not building on Windows 8.1 - failing with following error,
error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
I have tried the following,
- Setting an evironment variable
VCTargetsPath
toC:\Program Files (x86)\MSBuild\12.0\
(The error changes accordingly but there is noMicrosoft.Cpp.Default.props
with the 2012 build tools). - Installing a VisualStudio 2010 environment (uninstalled then installed in the correct order) according to this answer
- Completely removed VisualStudio 2010 and tried a VisualStudio 2012 instead, which should work according to the
Node-gyp
wiki - Added registry keys according to this answer
- Tried using the Windows 7.1 SDK command prompt according to this answer
- Tried setting
VisualStudioVersion
before running npm according to this answer - Tried passing
--msvs_version=2012
to npm according to this answer
None of the above have worked.
I've spent ages on this already. Does anyone have a definite answer that works?
C++ Solutions
Solution 1 - C++
The quick fix for me was this:
set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
npm install
Solution 2 - C++
Finally Microsoft is providing much better solution to VS.
Solution 3 - C++
I just wanted to update this question with the latest answer. You now do not need to install Visual Studio.
Source: https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245
Instructions below in case the source goes down.
-
Install VC++ Build Tools Technical Preview using the Default Install option. > [Windows 7 only] requires .NET Framework 4.5.1
-
Install Python 2.7, and add it to your PATH:
npm config set python python2.7
-
Launch cmd and run:
npm config set msvs_version 2015 --global
(this is instead of lnpm install [package name] --msvs_version=2015l
every time.)
Solution 4 - C++
So it is 2.47am - figured it out.
Although the node-gyp site seems to suggest using Visual Studio 2010 or 2012, instead for Windows 8.1, install Visual Studio Express 2013 for Windows Desktop as discussed in this issue.
Solution 5 - C++
Setting the following fixed the problem for me
/property:VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
As mentioned on this forum
Solution 6 - C++
A quick note for people who installed:
-
Visual Studio 2012 (Express)
-
MSBuild 2012
with the issue of:
-
MSBuild loads Microsoft.Cpp.Default.props
-
MSBuild cannot load Microsoft.Cpp.props
The solution is here: set parameter of MSBuild: /property:VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110"
Solution 7 - C++
This is the same issue as described here
If you have a version of VS2013 installed set this environment variable before running the npm command:
set GYP_MSVS_VERSION=2013
or for VS2012
set GYP_MSVS_VERSION=2012
background reading: https://github.com/Automattic/socket.io/issues/1151
Solution 8 - C++
Just in case people encounter this issue again, the issue got resolved in my case when I did a
npm install -g --production windows-build-tools