2015-09-18 119 views
0

我學習節點和socket.io,但我有一個問題,安裝socket.io 這裏就是我所做的:如何安裝socket.io

  1. 我創建了一個名爲它的文件夾nodejs
  2. 我創建嘗試使用這個命令來安裝插座app.js(無碼裏面還)
  3. `NPM安裝socket.io

而且我得到了這些錯誤消息:

C:\wamp\www\nodejs 
λ npm install socket.io 
/


> [email protected] install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil 
> node-gyp rebuild 

| 
C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil {git}{hg} 
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 
gyp ERR! stack  at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) 
gyp ERR! stack  at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 
gyp ERR! stack  at Object.oncomplete (evalmachine.<anonymous>:108:15) 
gyp ERR! System Windows_NT 6.2.9200 
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil 
gyp ERR! node -v v0.10.35 
gyp ERR! node-gyp -v v1.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 

> [email protected] install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate 
> node-gyp rebuild 


C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate {git}{hg} 
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 
stack  at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) 
gyp ERR! stack  at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 
gyp ERR! stack  at Object.oncomplete (evalmachine.<anonymous>:108:15) 
ERR! System Windows_NT 6.2.9200 
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate 
gyp ERR! node -v v0.10.35 
ERR! node-gyp -v v1.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 
\ 


> [email protected] install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate 
> node-gyp rebuild 

| 
C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate {git}{hg} 
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 
gyp ERR! stack  at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) 
gyp ERR! stack  at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 
gyp ERR! stack  at Object.oncomplete (evalmachine.<anonymous>:108:15) 
gyp ERR! System Windows_NT 6.2.9200 
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate 
gyp ERR! node -v v0.10.35 
gyp ERR! node-gyp -v v1.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 

> [email protected] install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil 
> node-gyp rebuild 


C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil {git}{hg} 
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 
gyp ERR! stack  at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) 
gyp ERR! stack  at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 
gyp ERR! stack  at Object.oncomplete (evalmachine.<anonymous>:108:15) 
gyp ERR! System Windows_NT 6.2.9200 
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil 
gyp ERR! node -v v0.10.35 
gyp ERR! node-gyp -v v1.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 
[email protected] node_modules\socket.io 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected]) 
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected]) 
├── [email protected] ([email protected], [email protected], [email protected], [email protected]) 
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) 

當我檢查我的文件夾時,有一個node_modules文件夾,裏面是socket.io。看起來不錯,但是你能告訴我我是如何得到這些錯誤的?我需要重新安裝nodejs嗎?或者我在安裝套接字時錯過了一些部分?

+2

見的重複[NPM - 無法安裝socket.IO(http://stackoverflow.com/questions/16469086/npm -cant-install-socket-io)以獲取詳細信息。安裝socket.io需要一些「構建」步驟,這些步驟需要某些工具超出npm。在這種情況下,您需要安裝適當版本的Python並安裝到您的路徑中,並且由於您在Windows上,您還需要一些C++構建工具。在Windows上安裝所有這些細節都在網上(我會看看我是否可以找到適當的鏈接)。 – jfriend00

+0

應當指出的是,'故宮安裝socket.io'是成功的在這裏(你可以看到在輸出端的模塊樹),而插件的依賴關係('UTF-8 validate'和'bufferutil')是可選和socket.io將沒有他們的功能就好。擁有這些插件純粹是一種性能優勢。 – mscdex

回答

1

stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

確保你已經安裝了Python並設置了指向安裝位置的環境變量。

2

Socket.io安裝正確。

沒有正確安裝的是一些可選的依賴項。

npm WARN optional dep failed, continuing ...

爲什麼有的DEPS沒有被正確安裝的原因是很清楚

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

所以你必須,如果你想安裝這些可選的依賴關係(你可能想)在你的系統中安裝Python。