8

我有 MS Visual Studio 2012 Ultimate,操作系统是 Windows 7,并安装了 nodeJs。我想使用 npm 安装 socket.io,但出现以下错误。

C:\Users\NEW>npm install socket.io
npm http GET https://registry.npmjs.org/socket.io
npm http 304 https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.11
npm http 304 https://registry.npmjs.org/base64id/0.1.0
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http 304 https://registry.npmjs.org/redis/0.7.3
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/ws
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/options
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
npm http 304 https://registry.npmjs.org/commander
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/options

> ws@0.4.25 install C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-c
lient\node_modules\ws

> (node-gyp rebuild 2> builderror.log) || (exit 0)

C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-client\node_modules\w
s>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild

Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe".
 If the component is not installed, either 1) install the Microsoft Windows SDK
 for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual
 Studio 2008.  [C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-clie
nt\node_modules\ws\build\binding.sln]

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe".
 If the component is not installed, either 1) install the Microsoft Windows SDK
 for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual
 Studio 2008.  [C:\Users\NEW\node_modules\socket.io\node_modules\socket.io-clie
nt\node_modules\ws\build\binding.sln]

socket.io@0.9.13 node_modules\socket.io
├── base64id@0.1.0
├── policyfile@0.0.4
├── redis@0.7.3
└── socket.io-client@0.9.11 (xmlhttprequest@1.4.2, uglify-js@1.2.5, active-x-obf
uscator@0.0.1, ws@0.4.25)

可能是什么问题?我该如何解决?

4

4 回答 4

13

很抱歉挖了一个老问题,但你的问题是我搜索“Socket.io VCBuild”时的第一个结果

StackOverflow上磕磕绊绊后,我找到的解决方案是:

npm install socket.io --msvs_version=2012

来自@petf-felzmann 的更新。如果您使用的是 VS 2015,您可以使用:

npm install socket.io --msvs_version=2015

于 2013-09-22T03:53:19.293 回答
1

安装 dotnet 3.5,这样 websockets 就可以编译了

http://www.microsoft.com/en-us/download/details.aspx?id=21

于 2013-01-17T14:19:59.063 回答
1

确保你有所有的必备软件来运行node-gyp

您可以gyp通过环境变量配置所使用的 Visual Studio 版本,这样您就可以避免设置--msvs_version=2012属性。

例子:

  • GYP_MSVS_VERSION=2012为 Visual Studio 2012设置
  • 设置GYP_MSVS_VERSION=2013e(“e”代表“特快版”)

有关完整列表,请参阅 - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

这对于 NodeJS 的 Windows 用户来说仍然很痛苦,因为它假定您安装了 Visual Studio 的副本,而许多最终用户永远不会拥有它。因此,我正在游说 Joyent 鼓励他们将 Web 套接字作为 CORE 节点的一部分,并可能将 GNU gcc 编译器作为 NodeJS 安装的一部分,这样我们就可以永久解决这个问题。

欢迎在以下位置添加您的投票:

于 2014-08-01T00:35:36.693 回答
-3

我想我找到了。尝试:

npm install websocket@1.0.3

我在这里找到了

于 2013-03-20T19:03:52.023 回答