Sunday, December 15, 2013

Building PouchDB on Windows 7

Building PouchDB on Windows 7 has been a rather miserable experience. Not because of PouchDB but because of the Microsoft Windows development tools: Visual Studio and Windows SKD.

For hours, every attempt to 'npm install' the PouchDB package failed with:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(29
7,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.
  TargetFrameworkVersion or PlatformToolset may be set to an invalid version nu
mber. [C:\Users\ian\Documents\Entrain\pouchdb\pouchdb-master\node_modules\level
\node_modules\leveldown\deps\leveldb\leveldb.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x
64.targets(146,5): error MSB6006: "CL.exe" exited with code -1073741515. [C:\Us
ers\ian\Documents\Entrain\pouchdb\pouchdb-master\node_modules\level\node_module
s\leveldown\deps\leveldb\leveldb.vcxproj]
The Internet is full of reports of this warning and this error. Most of them with only cryptic hints as to how to resolve them or nothing more than the comment "works for me". I spent over four hours installing, uninstalling, re-installing various packages from Microsoft and rebooting a mind-boggling number of times, following advice here and there. None of it made any difference. Always, the same warning and error.

Finally, I stumbled on https://github.com/node-xmpp/node-expat/issues/57 - an issue for node-expat. The last post there was from kosmobot:

@southrop you have to explicitly specify the Platform Toolset when building the solution with msbuild. Try one of these commands depending on your platform:
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
This actually solved the problem. So, I had all the prerequisites installed all along - the only problem was setting up the environment. Too bad none of Microsoft's replies to reports of the warning or error bother to mention this. If only I had found this post earlier, I might have done some useful work this morning. 

Much thanks to kosmobot!!

No comments:

Labels