【问题标题】:Can't install socket.io on Windows 7无法在 Windows 7 上安装 socket.io
【发布时间】:2013-03-02 06:26:21
【问题描述】:

我是 Node.js 和 NPM 的新手。我正在使用 Node v0.10.0,当我运行 npm install socket.io 命令时,我收到以下错误:

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]

我猜这是构建错误,所以我花了很多时间谷歌搜索和更新我的 Windows SDK、Visual Studio、.Net Framework 等。在一种或另一种形式中,我得到了上述错误。根据此链接https://connect.microsoft.com/VisualStudio/feedback/details/713415/erroneous-windows-sdk-x64-compilation-warning,警告可能是错误的,因为我在 x64 机器上。我确实看到 winsock2.h 位于 C:\Program Files\Microsoft SDKs\Windows\v7.1\Include 并已将其包含在我的路径中。我的路径包含以下内容:

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;

与此路径相同的错误。有什么想法吗?

【问题讨论】:

  • 您的安装是否有效?我经常收到在 Windows 上最终不会成为真正问题的警告。
  • 是的,尽管消息 socket.io 似乎正在工作。

标签: node.js windows-7 socket.io npm windows-7-x64


【解决方案1】:

我在尝试 npm install socket.io 时遇到了类似的问题。

从这里https://github.com/LearnBoost/socket.io/issues/1151#issuecomment-16015421

我最终设置了这个环境变量:

set GYP_MSVS_VERSION=2013

这是在安装 windows SP1(prep 安装程序)之后,然后是 SP1 安装程序,然后是 windows 更新的 101 更新,然后是 VS 2013 Express。

真的很简单:-/

【讨论】:

    【解决方案2】:

    在 Windows 7 x64 上安装节点存在问题。 基本上,在使用 msbuild 构建解决方案时,您必须明确指定平台工具集。 这是一个对我有用的解决方案: 在你的终端运行:

    调用“C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd”/Release /x64

    然后运行

    npm install socket.io

    更多信息here

    【讨论】:

    • 您应该在此处简要介绍链接的内容...如果链接失效,那么未来的读者可能无法弄清楚问题所在。
    • Ray C Lin,您可以将命令粘贴到 Windows shell 中。
    • 终于。我尝试了其他所有方法,这与以管理员身份运行一起对我有用。
    【解决方案3】:

    您是否以足够的权限启动 CMD 提示符?我偶尔遇到了 npm install 的问题。

    如果是这种情况,请以管理员身份运行 CMD。

    【讨论】:

    • 大多数情况下 npm install -g 工作得很好,但在 socket.io 要求“ws”上对我来说失败了。以管理员身份运行 CMD 并重新安装即可工作。
    • 太棒了,我很高兴它成功了! Nowwwww ...那个被接受的答案怎么样;)
    • 哦,这很烦人。我现在在另一台机器上收到此错误。我已经在哪里以管理员身份运行 CMD .....
    【解决方案4】:

    SO 尽管我的 cmets 认为以管理员身份运行 shell,但我在另一台我仍在以管理员身份运行 shell 的机器上遇到了这个问题。

    (为了搜索引擎的利益,下面是一个非常完整的错误摘录)

    这些错误似乎与我无法独立安装的 node-gyp 和提供帮助的 found some notes 有关:

    你需要:

    • Microsoft Visual Studio C++ 2010(Express 版本运行良好)
      • 我确实已经有了这个
    • 对于节点和本机模块的 64 位构建,您还需要 Windows 7 64-bit SDK
      • 此安装一直失败,然后我发现
      • _如果您拥有比 Visual C++ 2010 x86 Redistributable 版本 10.0.30319 更新的 vcredist_x86.exe,则不会安装 SDK 7.1。_ source

    • 我卸载了 10.0.[something > 30319]
    • 安装了 SDK 7.1
    • 然后能够毫无问题地npm i -g node-inspectorsocket.io 是一个依赖项)

    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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 2020-03-17
      • 2012-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多