Node packages not building on Windows 8.1 - Missing Microsoft.Cpp.Default.props

52,220

Solution 1

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 2

The quick fix for me was this:

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

Solution 3

Finally Microsoft is providing much better solution to VS.

Solution 4

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.

  1. Install VC++ Build Tools Technical Preview using the Default Install option.

    [Windows 7 only] requires .NET Framework 4.5.1

  2. Install Python 2.7, and add it to your PATH: npm config set python python2.7

  3. 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 5

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

Share:
52,220
Brendan
Author by

Brendan

Was a physicist, now a freelance technologist and UX designer Most at home with C#, XAML, Javascript and Python with experience in lots of other languages and technologies.

Updated on July 09, 2022

Comments

  • Brendan
    Brendan almost 2 years

    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 to C:\Program Files (x86)\MSBuild\12.0\ (The error changes accordingly but there is no Microsoft.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?

  • eXavier
    eXavier almost 10 years
    Where to specify /property ? If specified to npm install it is not passed to MSBuild..
  • Tom Mayfield
    Tom Mayfield over 9 years
    You can edit C:\Windows\Microsoft.NET\Framework\v<Version>\msbuild.rsp to set up global MSBuild properties.
  • Richard
    Richard over 8 years
    And if this folder doesn't exist on your machine install the latest VS Community IDE visualstudio.com/en-us/products/visual-studio-community-vs.a‌​spx and restart. This new folder will be set by default: C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140.
  • ericgrosse
    ericgrosse over 8 years
    In my case, had to switch V120 to V140 for this to work. Make sure to actually check where the directory path leads in explorer.
  • rudnev
    rudnev over 8 years
    yup, looks like that helps regardless of other VS stuff preinstalled
  • Barry Staes
    Barry Staes over 8 years
    I have the same issue (1) but with Visual Studio 2015. The imported project "C:\Microsoft.Cpp.Default.props" was not found. So i recon i should use C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140 (the path exists) but where to set this MSBuild parameter?
  • apardoe
    apardoe almost 8 years
    Direct link for Visual C++ Build Tools (the subject of the GitHub comment linked above): landinghub.visualstudio.com/visual-cpp-build-tools
  • apardoe
    apardoe almost 8 years
    The VC++ Build Tools link above is broken. Better link is here: landinghub.visualstudio.com/visual-cpp-build-tools
  • Kumar S
    Kumar S over 7 years
    I can't edit C:\Windows\Microsoft.NET\Framework\v<Version>\msbuild.rsp. I get the warning, 'Please check this file is opened in another program' But I don't have any other program running.
  • Ashbay
    Ashbay almost 6 years
    This quick fix works also to make node-openzwave-shared compile (github.com/OpenZWave/node-openzwave-shared)
  • Gavin
    Gavin over 5 years
    New link to download build tools visualstudio.microsoft.com/downloads/…
  • Nameless
    Nameless over 5 years
    PowerShell version: [Environment]::SetEnvironmentVariable("VCTargetsPath", "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140", "Machine")