Can't install socket.io on Windows 7
Asked Answered
G

4

17

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?

Gerah answered 14/3, 2013 at 2:40 Comment(2)
does your installation work? I often get warnings that don't end up being real issues on Windows.Illuminati
yes, despite the messages socket.io appears to be working.Gerah
M
10

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

Mensural answered 25/5, 2014 at 20:10 Comment(0)
A
5

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

Amenity answered 9/10, 2014 at 17:53 Comment(3)
You should give a brief synopsis of the link's contents here... If the link goes down, then future readers might not be able to figure out what the problem was.Ginnie
Ray C Lin, you can just paste the command into the Windows shell.Amenity
FINALLY. I tried everything else and this worked for me in conjunction with running as administrator.Keyser
E
2

Are you launching the CMD prompt with sufficient permissions? I have had issues with npm install on occasion b/c of this.

If this is the case jst run CMD as administrator.

Erythrism answered 12/5, 2013 at 14:41 Comment(3)
Mostly npm install -g <packagename> works just fine, but it was failing for me on the socket.io requirement "ws". Running CMD as administrator and re-installing got it to work.Svensen
Awesome, I am so glad it worked! Nowwwww... how 'bout that accepted answer ;)Erythrism
Oh, this is annoying. I'm now getting this error on a different machine. WHERE I AM RUNNING CMD AS ADMINISTRATOR ALREADY.....Svensen
S
2

SO despite my comments regarding running shell as administrator working, I ran into this problem on another machine where I was still running shell as administrator.

(A pretty-much-complete extract of the errors are below, for benefit of search-engines)

The errors seemed related to node-gyp which I was unable to install standalone, and found some notes that helped out:

You need:

  • Microsoft Visual Studio C++ 2010 (Express version works well)
    • I did already have this
  • For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
    • This install kept failing, and then I found that
    • _the SDK 7.1 does NOT install if you have a newer vcredist_x86.exe than version 10.0.30319 of Visual C++ 2010 x86 Redistributable._ source

  • I uninstalled 10.0.[something > 30319]
  • Installed the SDK 7.1
  • and was then able to npm i -g node-inspector with no problems (socket.io is a dependency)

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(296,5): warning MSB800
3: Could not find VCInstallDir variable from the registry.  TargetFrameworkVersion or PlatformTools
et may be set to an invalid version number. [C:\Users\Michael Paulukonis\AppData\Roaming\npm\node_m
odules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]

  bufferutil.cc

c:\users\michael paulukonis\.node-gyp\0.10.5\deps\v8\include\v8stdint.h(33): fatal error C1083: Can
not open include file: 'stddef.h': No such file or directory [C:\Users\Michael Paulukonis\AppData\R
oaming\npm\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vc
xproj]

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(296,5): warning MSB800
3: Could not find VCInstallDir variable from the registry.  TargetFrameworkVersion or PlatformTools
et may be set to an invalid version number. [C:\Users\Michael Paulukonis\AppData\Roaming\npm\node_m
odules\socket.io\node_modules\socket.io-client\node_modules\ws\build\validation.vcxproj]

  validation.cc

c:\users\michael paulukonis\.node-gyp\0.10.5\deps\v8\include\v8stdint.h(33): fatal error C1083: Can
not open include file: 'stddef.h': No such file or directory [C:\Users\Michael Paulukonis\AppData\R
oaming\npm\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws\build\validation.vc
xproj]
Svensen answered 23/11, 2013 at 3:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.