我正在尝试在Macbook(Mavericks)上安装socket.io,每次尝试时都会出现以下错误。我有Node.js 10.29和Express 4.4.5以及Jade 1.3.1。
Nicks-MacBook-Pro:Node nick$ npm install socket.io
> ws@0.4.31 install/Users/nick/Node/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
> ws@0.4.31 install /Users/nick/Node/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
socket.io@1.0.6 node_modules/socket.io
├── debug@0.7.4
├── has-binary-data@0.1.1 (isarray@0.0.1)
├── socket.io-parser@2.2.0 (isarray@0.0.1, emitter@1.0.1, json3@3.2.6)
├── socket.io-adapter@0.2.0 (socket.io-parser@2.1.2)
├── engine.io@1.3.1 (base64id@0.1.0, debug@0.6.0, engine.io-parser@1.0.6, ws@0.4.31)
└── socket.io-client@1.0.6 (to-array@0.1.3, indexof@0.0.1, component-bind@1.0.0, object-component@0.0.3, component-emitter@1.1.2, parseuri@0.0.2, engine.io-client@1.3.1)
我试图忽略错误,但不幸的是,这对我的应用程序来说是致命的,因为当我尝试运行应用程序时会产生以下错误:
SyntaxError: /Users/nick/Node/views/chat.jade:10 8| document.getElementById('chat').innerHTML = 9| '<p><b>' + data.title + '</b>: ' + data.contents + '</p>'; > 10| }); 11| var submitChat = function(form){ 12| socket.emit('chat', {text: form.chat.value}); 13| return false; Unexpected token ; at Function (<anonymous>) at assertExpression (/Users/nick/Node/node_modules/jade/lib/lexer.js:30:3) at Object.Lexer.attrs (/Users/nick/Node/node_modules/jade/lib/lexer.js:647:20) at Object.Lexer.next (/Users/nick/Node/node_modules/jade/lib/lexer.js:867:15) at Object.Lexer.lookahead (/Users/nick/Node/node_modules/jade/lib/lexer.js:113:46) at Parser.lookahead (/Users/nick/Node/node_modules/jade/lib/parser.js:100:23) at Parser.peek (/Users/nick/Node/node_modules/jade/lib/parser.js:77:17) at Parser.tag (/Users/nick/Node/node_modules/jade/lib/parser.js:733:22) at Parser.parseTag (/Users/nick/Node/node_modules/jade/lib/parser.js:719:17) at Parser.parseExpr (/Users/nick/Node/node_modules/jade/lib/parser.js:188:21)
感谢您的帮助!