microsoft / node-uwp

Enables Universal Windows Platform (UWP) API access for Node.js (Chakra build) on Windows 10.
MIT License
152 stars 26 forks source link

build: Wrong Windows SDK version #19

Open jianchun opened 8 years ago

jianchun commented 8 years ago

Reported by @grownseed in #11

Thanks @hgwood but still no luck... I've removed anything Node-related on my system, installed Node.js with Chakra, re-installed Visual Studio Community 2015 with Visual C++, Visual Studio Extensibility Tools Update 1, Windows 10 SDK, Universal Windows App Development Tools, rebooted, added GYP_MSVS_VERSION 2015 to my environment variables, npm config set python c:\python2.7\python.exe.

where node:

C:\Program Files\NodejsUwp\Console\node.exe

where npm:

C:\Program Files\NodejsUwp\Console\npm
C:\Program Files\NodejsUwp\Console\npm.cmd

where node-gyp:

C:\Program Files\NodejsUwp\Console\node_modules\npm\bin\node-gyp-bin\node-gyp
C:\Program Files\NodejsUwp\Console\node_modules\npm\bin\node-gyp-bin\node-gyp.cmd

Attempting to npm install uwp:

[...]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\prsht.h(607): error C2146: s
yntax error : missing ';' before identifier 'hdr' [C:\Users\Hadrien\Documents\D
ev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\prsht.h(607): error C4430: m
issing type specifier - int assumed. Note: C++ does not support default-int [C:
\Users\Hadrien\Documents\Dev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h(247): warning C419
3: #pragma warning(pop) : no matching '#pragma warning(push)' [C:\Users\Hadrien
\Documents\Dev\bb\node_modules\uwp\build\uwp.vcxproj]
C:\Program Files\NodejsUwp\Console\sdk\deps\chakrashim\include\v8.h(65): fatal
error C1189: #error :  Wrong Windows SDK version [C:\Users\Hadrien\Documents\De
v\bb\node_modules\uwp\build\uwp.vcxproj]
[...]

Of particular note is Wrong Windows SDK version, it looks like it's pointing to the Windows 8.1 Kit, even though I do have the Windows 10 Kit available. I'm now stuck trying to figure out how to tell node-gyp to use the correct kit (if that's actually what's going on here...).

munyirik commented 8 years ago

The SDK is set in C:\Program Files (x86)\NodejsUwp\Console\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py. Looks like it's either a problem in _ConfigWindowsTargetPlatformVersion or the SDK isn't in the registry.

munyirik commented 8 years ago

@grownseed does the the folder C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0 exist on your PC?

grownseed commented 8 years ago

@munyirik Thank you for looking into this.

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0 is indeed present on my PC.

Perhaps more interestingly, I found that HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows contains v7.1, v7.1A, v8.0A and v8.1A, but no v10.0A version.

In case it is relevant, under C:\Program Files (x86)\Microsoft SDKs\Windows, I have v7.0A, v7.1A, v8.0, v8.0A, v8.1, v8.1A and v10.0A.

I tried to repair Visual Studio as well as reinstalling it, to no effect. I also tried running Visual Studio and creating a new project to see if I could install missing dependencies, but again, no luck there.

Please let me know if you need further information.

munyirik commented 8 years ago

Can you try installing the standalone SDK from here - https://dev.windows.com/en-us/downloads/windows-10-sdk?

grownseed commented 8 years ago

It tells me I need to uninstall my current Windows 10 SDK version.

Instead, I simply added the keys by hand in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows for 10.0A as such:

I also found out that for some reason the Node.js (Chakra) command prompt seems to ignore the GYP_MSVS_VERSION environment variable, so I added --msvs_version=2015 to npm install uwp (I had tried that before having the registry keys in place and that did not work).

I've been able to install node-uwp successfully and it looks like everything is working now, though I'm still testing.

Thank you for the pointers, hopefully there ends up being a slightly less cumbersome way of making this work.

jianchun commented 8 years ago

The registry on my box is actually the same as yours before change. Maybe that's not the problem.

Maybe the key in your fix is --msvs_version=2015, as we just realized this would happen if the tools picked VS2013.

On my box:

Is there any possibility that you had similar GYP_MSVS_VERSION settings before? @grownseed

grownseed commented 8 years ago

@jianchun I double-checked before trying and I did have GYP_MSVS_VERSION=2015 set, node-gyp just doesn't seem to pick it up in my case. I also tried npm install uwp --msvs_version=2015 before making the changes I mentioned previously and that gave me the same error.

Regarding the registry keys, is it possible that you have them setup under HKEY_CURRENT_USER? I read somewhere that node-gyp will pick that up first, but that's a pretty wild guess on my part.

If the registry keys aren't the issue, the only thing I can think of is that creating a new C++ project in Visual Studio somehow fixed something, though I honestly couldn't tell you why, sorry.

jianchun commented 8 years ago

I checked again, I have HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0. I don't have one without WOW6432Node.

grownseed commented 8 years ago

Interesting, I just checked and that key does exist for me too. I'm not sure why it would be picked up in your case and not mine, I'll keep looking around.