App下載
話題 首頁 > Node.js 教程 > Node.js 教程話題列表 > 詳情

websocket的后端服務(wù)啟動(dòng)出錯(cuò)

精華
碼友1533852 2019-10-26 23:17:20 瀏覽(1806) 回復(fù)(0) 贊(0)
按照下面連接來搭建websocket。 新建了一個(gè)server.js文件 console .log( "Server started" );1. var Msg = '' ;1. var WebSocketServer = require ( 'ws' ).Server1. , wss = new WebSocketServer({ port : 8010 });1. wss.on( 'connection' , function ( ws ) {1. ws.on( 'message' , function ( message ) {1. console .log( 'Received from client: %s' , message);1. ws.send( 'Server received from client: ' + message);1. });1. }); node server.js 時(shí)候,出現(xiàn)如下錯(cuò)誤。 Server started /root/node_modules/ws/lib/websocket.js:347 ...options ^^^ SyntaxError: Unexpected token ... at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10) at Module._compile (module.js:549:28) at Object.Module._extensions..js (module.js:586:10) at Module.load (module.js:494:32) at tryModuleLoad (module.js:453:12) at Function.Module._load (module.js:445:3) at Module.require (module.js:504:17) at require (internal/module.js:20:19) at Object. (/root/node_modules/ws/index.js:3:19) https://www.oschina.net/translate/websocket-nginx
nodejs

回答(0)

要回復(fù),請(qǐng)先登錄 或者注冊(cè)