簡體   English   中英

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

[英]How to install socket.io on windows 7 x64 (node.js)

在Windows 7家庭高級版64位上運行

下載:

然后按照http://blog.nowjs.com/running-nowjs-natively-on-windows上的步驟進行操作,其中暗示:

  • 安裝Microsoft Visual C ++運行時(我得到了x64版本)
  • 從github.com/Flotype/now/zipball/windows抓取now.js的'fixed-for-windows'版本

一切就緒后,運行任何需要'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。

另外,將fixed.js的fixed-for-windows版本直接放在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)

任何在谷歌上發現這個問題的人:我正在運行Windows 8 x64,由於編譯器問題,嘗試將socket.io和其他擴展安裝到node.js有很多問題。

我嘗試下載/安裝GNU Make,Visual Studio Express,Visual Studio Ultimate(試用版):基本上是推薦的一切。 仍然沒有骰子。 Socket.io不會工作。

對我來說最簡單的解決方案就是在虛擬機中運行linux並使用該節點。 - 下載x86版本的Lubuntu Linux(非常類似windows): http//lubuntu.net/ - 在VirtualBox中安裝Linux: https//www.virtualbox.org/ - 在VirtualBox的網絡設置中使用“橋接適配器” Lubuntu。 這將允許您從Windows計算機訪問節點服務器。 - 在Lubuntu上安裝節點和其他任何你想要的東西。 Node最初是為linux設計的,所以一切都運行得很完美。 - 帶有一些額外功能的最終安裝只需要4GB的硬盤。 一點也不差!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM