我是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;
此路径的错误相同。有什么想法吗?
答案 0 :(得分:10)
我在尝试npm install socket.io
时遇到了类似的问题从这里https://github.com/LearnBoost/socket.io/issues/1151#issuecomment-16015421
我最终设置了这个环境变量:
set GYP_MSVS_VERSION=2013
这是在安装Windows SP1(准备安装程序)之后,然后SP1安装程序然后101更新从Windows更新,然后VS 2013 Express。
很容易: - /
答案 1 :(得分:5)
Windows 7 x64上的节点安装存在问题。 基本上,在使用msbuild构建解决方案时,必须明确指定Platform Toolset。 这是一个适合我的解决方案: 在您的终端运行中:
调用“C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ bin \ Setenv.cmd”/ Release / x64
然后运行
npm install socket.io
更多信息here
答案 2 :(得分:2)
您是否以足够的权限启动CMD提示?我有时遇到过npm安装问题。
如果是这种情况,jst以管理员身份运行CMD。
答案 3 :(得分:2)
SO 尽管我有关于以管理员身份运行shell的评论,我在另一台机器上遇到了这个问题,我仍在以管理员身份运行shell。
(为了搜索引擎的利益,下面的错误提取非常完整)
错误似乎与node-gyp
无关,而我无法单独安装,而found some notes则有所帮助:
你需要:
npm i -g node-inspector
没有问题(socket.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]