如何在 Windows 7 x64 上安装 socket.io(node.js)

3

运行在 Windows 7 Home Premium 64 位系统上

已下载:

然后按照 http://blog.nowjs.com/running-nowjs-natively-on-windows 上的步骤进行操作,其中包括:

  • 安装 Microsoft Visual C++ 运行库(我使用了 x64 版本)
  • 从 github.com/Flotype/now/zipball/windows 获取适用于 Windows 的 'now.js' 版本

一切就绪后,运行任何需要 'now' 模块的示例都会请求 'socket.io' 模块。

运行 'npm install socket.io -g' 命令输出:

C:\Windows\System32>npm install socket.io -g
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/policyfile/0.0.4
npm http GET https://registry.npmjs.org/socket.io-client/0.9.10
npm http GET https://registry.npmjs.org/redis/0.7.2
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.10
npm http 304 https://registry.npmjs.org/redis/0.7.2
npm http GET https://registry.npmjs.org/hiredis
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/hiredis
npm WARN package.json hiredis@0.1.14 No README.md file found!

> hiredis@0.1.14 preinstall C:\Program Files\nodejs\node_modules\socket.io\node_
modules\redis\node_modules\hiredis
> make || gmake

cd deps/hiredis && make static
process_begin: CreateProcess(NULL, sh -c "type cc >/dev/null 2>/dev/null && echo
 cc || echo gcc", ...) failed.
process_begin: CreateProcess(NULL, sh -c "uname -s 2>/dev/null || echo not", ...
) failed.
make[1]: Entering directory `C:/Program Files/nodejs/node_modules/socket.io/node
_modules/redis/node_modules/hiredis/deps/hiredis'
std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g
-ggdb net.c
'std' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
make[1]: [net.o] Error 1 (ignored)
std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g
-ggdb hiredis.c
'std' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
make[1]: [hiredis.o] Error 1 (ignored)
std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g
-ggdb sds.c
'std' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
make[1]: [sds.o] Error 1 (ignored)
std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g
-ggdb async.c
'std' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
make[1]: [async.o] Error 1 (ignored)
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
process_begin: CreateProcess(NULL, ar rcs libhiredis.a net.o hiredis.o sds.o asy
nc.o, ...) failed.
make (e=2): O sistema não pode encontrar o arquivo especificado.
make[1]: *** [libhiredis.a] Error 2
make[1]: Leaving directory `C:/Program Files/nodejs/node_modules/socket.io/node_
modules/redis/node_modules/hiredis/deps/hiredis'
make: *** [all] Error 2
'gmake' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
npm WARN optional dep failed, continuing hiredis@0.1.14
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/tinycolor
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.21 install C:\Program Files\nodejs\node_modules\socket.io\node_modules\
socket.io-client\node_modules\ws
> node install.js

[ws v0.4.21] Attempting to compile blazing fast native extensions.
[ws v0.4.21] Native code compile failed (but the module will still work):
[ws v0.4.21] The native extensions are faster, but not required.
[ws v0.4.21] On Windows, native extensions require Visual Studio and Python.
[ws v0.4.21] On Unix, native extensions require Python, make and a C++ compiler.

[ws v0.4.21] Start npm with --ws:verbose to show compilation output (if any).
socket.io@0.9.10 C:\Program Files\nodejs\node_modules\socket.io
+-- policyfile@0.0.4
+-- redis@0.7.2
+-- socket.io-client@0.9.10 (xmlhttprequest@1.4.2, uglify-js@1.2.5, active-x-obf
uscator@0.0.1, ws@0.4.21)

我有所不知吗?我也尝试过使用0.8.6-x64和0.8.5-x64版本的node.js,两者都被打包成msi格式。

此外,将修复后的now.js版本直接放入node_modules文件夹中,并在helloworld_server.js示例中运行“node helloworld_server.js”会产生以下结果:

[Error: no errorc:\xampp\htdocs\node-tcg\node_modules\now\bin\proxy.node]
Error: no errorc:\xampp\htdocs\node-tcg\node_modules\now\bin\proxy.node
    at Object.Module._extensions..node (module.js:485:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (c:\xampp\htdocs\node-tcg\node_modules\now\lib\proxy.j
s:10:13)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
1个回答

0

任何在谷歌上找到这篇文章的人: 我正在运行 Windows 8 x64,尝试安装 socket.io 和其他扩展到 node.js 时遇到了很多编译器问题。

我尝试下载/安装 GNU Make、Visual Studio Express、Visual Studio Ultimate(试用版):基本上是所有推荐的东西。但仍然不行。Socket.io 就是不工作。

对我来说最简单的解决方案就是在虚拟机中运行 Linux 并从其中使用 node。 - 下载 Lubuntu Linux 的 x86 版本(非常类似于 Windows):http://lubuntu.net/ - 在 VirtualBox 中安装 Linux:https://www.virtualbox.org/ - 在 VirtualBox 的网络设置中使用“桥接适配器”来连接 Lubuntu。这将允许您从 Windows 计算机访问 node 服务器。 - 在 Lubuntu 上安装 node 和其他您想要的内容。Node 最初是为 Linux 设计的,所以一切都可以完美地运行。 - 安装最终版本和一些额外的内容只需要占用我的硬盘 4GB。非常不错!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接