justadudewhohacks/websocket-chat

Unexpected token ...

coneheadusa opened this issue · 2 comments

After cloning your project, successfully running' npm install', I get the following errors when I execute 'npm run server':
`

websocket-chat@0.0.0 server /var/www/html/srptApp/websocket-chat
node ./server/server.js
/var/www/html/srptApp/websocket-chat/server/handlers.js:37
const entry = { user, ...createEntry() }
---------------------^^^
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. (/var/www/html/srptApp/websocket-chat/server/server.js:6:22)
npm ERR! Linux 3.10.0-862.3.2.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "server"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! websocket-chat@0.0.0 server: node ./server/server.js
npm ERR! Exit status 1
npm ERR!
`

Please advise.

Hi,

Node 6 doesn't know about the object-rest-spread operator "...". You can either upgrade node to a recent version or use babel to transpile the code if you have to use node 6.

@coneheadusa Consider updating your Nodejs and It will work!