Can't install socket.io on Windows 7

landland picture landland · Mar 14, 2013 · Viewed 9.6k times · Source

I am new to Node.js and NPM. I am using Node v0.10.0 and when I run the npm install socket.io command I get the following error:

C:\Users\USER\AppData\Roaming\npm\node_modules\socket.io\node_modules\socket.io-
client\node_modules\ws>node "C:\Users\USER\AppData\Roaming\npm\node_modules\npm\
bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
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\USER\AppData\Roaming\npm\node_modules\socket.io\node_modules\so
cket.io-client\node_modules\ws\build\bufferutil.vcxproj]
bufferutil.cc
c:\users\user\.node-gyp\0.10.0\deps\uv\include\uv-private/uv-win.h(32): fatal e
rror C1083: Cannot open include file: 'winsock2.h': No such file or directory [
C:\Users\USER\AppData\Roaming\npm\node_modules\socket.io\node_modules\socket.io
-client\node_modules\ws\build\bufferutil.vcxproj]

I guess this is a build error so I spent a bunch of time Googling and updating my Windows SDK, Visual Studio, .Net Framework, and so on. In one form or another I get the above error. According to this link https://connect.microsoft.com/VisualStudio/feedback/details/713415/erroneous-windows-sdk-x64-compilation-warning the warning is possibly erroneous as I am on an x64 machine. I do see that winsock2.h is located in C:\Program Files\Microsoft SDKs\Windows\v7.1\Include and have included that in my path. My path contains the following:

C:\Program Files\nodejs\;
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcpackages;
C:\Program Files\Microsoft Windows Performance Toolkit\;
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include;
C:\Program Files\Debugging Tools for Windows (x64)\winext\manifest;
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;

Same error with this path. Any ideas?

Answer

Adam Straughan picture Adam Straughan · May 25, 2014

I Searched far and wide with a similar problem trying to npm install socket.io

From here https://github.com/LearnBoost/socket.io/issues/1151#issuecomment-16015421

I ended up setting this environment variable:

set GYP_MSVS_VERSION=2013

This was after installing windows SP1 (prep installer) then the SP1 installer then 101 updates from windows updates then VS 2013 Express.

Easy really :-/