2015-10-06 117 views
0

我剛剛嘗試使用以下指令創建基本聊天應用程序http://socket.io/get-started/chat/基本聊天應用程序使用Socket.io和Node js創建

當我試圖運行npm install --save socket.io

我收到以下錯誤。如何解決以下錯誤:

npm WARN package.json [email protected] No repository field. 
npm WARN package.json [email protected] No README data 
npm WARN package.json [email protected] No license field. 

> [email protected] install /root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil 
> node-gyp rebuild 

make: Entering directory `/root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil/build' 
    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o 
make: g++: Command not found 
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 127 
make: Leaving directory `/root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil/build' 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23) 
gyp ERR! stack  at ChildProcess.emit (events.js:110:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:1074:12) 
gyp ERR! System Linux 3.13.0-55-generic 
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
cwd /root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil 
gyp ERR! node -v v0.12.7 
gyp ERR! node-gyp -v v2.0.1 
gyp ERR! not ok 

> [email protected] install /root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate 
> node-gyp rebuild 

make: Entering directory `/root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build' 
    CXX(target) Release/obj.target/validation/src/validation.o 
make: g++: Command not found 
make: *** [Release/obj.target/validation/src/validation.o] Error 127 
make: Leaving directory `/root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate/build' 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23) 
gyp ERR! stack  at ChildProcess.emit (events.js:110:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:1074:12) 
gyp ERR! System Linux 3.13.0-55-generic 
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /root/chat-example/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate 
gyp ERR! node -v v0.12.7 
gyp ERR! node-gyp -v v2.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 

> [email protected] install /root/chat-example/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 

make: Entering directory `/root/chat-example/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate/build' 
    CXX(target) Release/obj.target/validation/src/validation.o 
make: g++: Command not found 
make: *** [Release/obj.target/validation/src/validation.o] Error 127 
make: Leaving directory `/root/chat-example/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate/build' 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23) 
gyp ERR! stack  at ChildProcess.emit (events.js:110:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:1074:12) 
gyp ERR! System Linux 3.13.0-55-generic 
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /root/chat-example/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.12.7 
gyp ERR! node-gyp -v v2.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 

> [email protected] install /root/chat-example/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil 
> node-gyp rebuild 

make: Entering directory `/root/chat-example/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil/build' 
    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o 
make: g++: Command not found 
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 127 
make: Leaving directory `/root/chat-example/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil/build' 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23) 
gyp ERR! stack  at ChildProcess.emit (events.js:110:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:1074:12) 
gyp ERR! System Linux 3.13.0-55-generic 
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /root/chat-example/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.12.7 
gyp ERR! node-gyp -v v2.0.1 
gyp ERR! not ok 
npm WARN optional dep failed, continuing [email protected] 
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], backo[email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) 

請檢查此錯誤,是什麼原因造成的問題?

請建議

+0

你使用的是什麼操作系統?以及你是如何安裝node.js的? –

+0

@Kichu嘗試'sudo npm install socket.io --save' –

回答

1

你試過安裝node-gyp和g ++嗎?

npm install -g node-gyp 

和g ++

apt-get install g++