npm install -g karma error MSB4019: The imported project “C:\\Microsoft.Cpp.Default.props” was not found

≡放荡痞女 提交于 2019-11-27 11:43:39

I had the same issue with other modules after installing VS Express 2013 for web alongside VS Express 2012 for Windows. The solution was to install VS 2013 for Windows and use the switch

npm install --msvs_version=2013

For those that still run into errors after installing a VS with Windows SDK and trying Besrl's solution, in particular node-gyp failing with

Error MSB4019: The imported project "X:\Microsoft.Cpp.Default.props" was not found,

Try running the npm install commands from a MSVS command prompt.

Find it at Start menu > Microsoft Visual Studio 201X > Visual Studio Tools > Open Visual Studio 201X Tools Command Prompt or run the <Program Files>\<VS dir>\Common7\Tools\VsDevCmd.bat from a command prompt.

The above worked for me with VS2012, and this Github comment helped me find that.

Make sure you have all the required software to run node-gyp:

You can configure the version of Visual Studio used by gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property for future installs.

Examples:

  • set GYP_MSVS_VERSION=2012 for Visual Studio 2012
  • set GYP_MSVS_VERSION=2013e (the 'e' stands for 'express edition')

For the full list see - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

This is still painful for Windows users of NodeJS as it assumes you have a copy of Python and Visual Studio installed but many end users will never have this. So I'm lobbying Joyent to encourage them to include web sockets as part of CORE node and also to ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.

Feel free to add your vote at:

On windows the easiest way that i found to fix this is to install the windows-build-tools as recommended by the README for node-gyd

npm install --global --production windows-build-tools

https://github.com/nodejs/node-gyp

This way i didnt have to mess with installing python or other dist packages myself.

JD Smith

If you don't have Visual Studio installed at all, then you definitely need the answer at https://stackoverflow.com/a/18779641/530967.

Basically you have to install some version of Visual Studio 2010 (Express version is free), then the Windows SDK, then VS SP1, then a VC++ compiler update, all in that order. After that this problem should disappear (as it did for me.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!