Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install socket.io on Windows 7

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?

like image 360
landland Avatar asked Mar 14 '13 02:03

landland


People also ask

What is Socket.IO error?

Error − An error event is sent from the server. Message − When the server sends a message using the send function. Reconnect − When reconnection to the server is successful. Reconnecting − When the client is in the process of connecting.

Can you use Socket.IO without node JS?

The short answer is yes. You will however have Flash dependency. You can read about how to do this in socket. io's faq.


2 Answers

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 :-/

like image 73
Adam Straughan Avatar answered Sep 20 '22 13:09

Adam Straughan


There is an issue with node installation on Windows 7 x64. Basically, you have to explicitly specify the Platform Toolset when building the solution with msbuild. Here's a solution that worked for me: in your terminal run:

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64

then run

npm install socket.io

More information here

like image 38
user2961443 Avatar answered Sep 18 '22 13:09

user2961443