在Windows 7 x64位環境下通過Express 3.x安裝socket.io包讓我非常難。獲取socket.io以在Windows 7 x64位平臺上工作
我不得不理清幾十或編譯錯誤,我必須安裝以下的Windows 7包安裝過程中輸出沒有錯誤:
- Cygwin的C++編譯器
- Cygin C++額外庫
- Microsoft Visual Studio 2010 Express
- Microsoft .NET Framework v2.0
- Microsoft Performance Toolkit Microsoft Windows SDK 7.1
- 用於Windows SDK 7.1的Microsoft Visual C++ 2010 SP1編譯器更新。
(Visual Studio的編譯器給了我一個警告C4267(參見下文))
儘管正確安裝,我依然有客戶端錯誤:
Error: io is not defined
var socket = io.connect('/');
我跟着建議爲socket.io.js
到由nodejs服務器提供app.js服務:
var express = require('express')
, http = require('http');
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
jad中的客戶端偏差Ë文件是:
script(src='/socket.io/socket.io.js')
而對於socket.io我的客戶端腳本節:
var socket = io.connect('/');
socket.io安裝到node-login
目錄這就是位於我app/public
和app/server
目錄。
socket.io安裝日誌:
D:\dev\node-login>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/active-x-obfuscator/0.0.1
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/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/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/options
> [email protected] install D:\dev\node-login\node_modules\socket.io\node_modules\socket
.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
D:\dev\node-login\node_modules\socket.io\node_modules\socket.io-client\node_modu
les\ws>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\no
de_modules\node-gyp\bin\node-gyp.js" rebuild
bufferutil.cc
..\src\bufferutil.cc(55): warning C4267: 'initializing' : conversion from 'size
_t' to 'unsigned int', possible loss of data [D:\dev\node-login\node_modules\so
cket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
..\src\bufferutil.cc(66): warning C4267: 'initializing' : conversion from 'size
_t' to 'unsigned int', possible loss of data [D:\dev\node-login\node_modules\so
cket.io\node_modules\socket.io-client\node_modules\ws\build\bufferutil.vcxproj]
C:\Users\Vivaldi\.node-gyp\0.8.17\deps\v8\include\v8.h(183): warning C4506: no
definition for inline function 'v8::Persistent<T> v8::Persistent<T>::New(v8::Ha
ndle<T>)' [D:\dev\node-login\node_modules\socket.io\node_modules\socket.io-clie
nt\node_modules\ws\build\bufferutil.vcxproj]
with
[
T=v8::Object
]
Creating library D:\dev\node-login\node_modules\socket.io\node_modules\soc
ket.io-client\node_modules\ws\build\Release\bufferutil.lib and object D:\dev\
node-login\node_modules\socket.io\node_modules\socket.io-client\node_modules\
ws\build\Release\bufferutil.exp
Generating code
Finished generating code
bufferutil.vcxproj -> D:\dev\node-login\node_modules\socket.io\node_modules\s
ocket.io-client\node_modules\ws\build\Release\\bufferutil.node
validation.cc
C:\Users\Vivaldi\.node-gyp\0.8.17\deps\v8\include\v8.h(183): warning C4506: no
definition for inline function 'v8::Persistent<T> v8::Persistent<T>::New(v8::Ha
ndle<T>)' [D:\dev\node-login\node_modules\socket.io\node_modules\socket.io-clie
nt\node_modules\ws\build\validation.vcxproj]
with
[
T=v8::Object
]
Creating library D:\dev\node-login\node_modules\socket.io\node_modules\soc
ket.io-client\node_modules\ws\build\Release\validation.lib and object D:\dev\
node-login\node_modules\socket.io\node_modules\socket.io-client\node_modules\
ws\build\Release\validation.exp
Generating code
Finished generating code
validation.vcxproj -> D:\dev\node-login\node_modules\socket.io\node_modules\s
ocket.io-client\node_modules\ws\build\Release\\validation.node
[email protected] node_modules\socket.io
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected] ([email protected], [email protected], active-x-obf
[email protected], [email protected])
D:\dev\node-login>
爲什麼客戶端無法找到socket.io.js?
你使用最新的node.js嗎? – Chris
我知道你會爲此付出代價,但我也是一個windows傢伙,我喜歡node.js.我被認爲是Linux上的noob,但是我發現linux更容易與node.js一起使用。 –
@Chris是的,它是Windows的nodejs的最新版本。第一個編譯錯誤是在stdint.h中找不到的。我不知道爲什麼它在尋找這個MS Visual Studio 2010文件。 – floflo