-1

I'm getting an error when I try to run my node.I have installed ws and websocket, but seems that none is working

Image of error

scrappedcola
  • 10,423
  • 1
  • 32
  • 43

2 Answers2

2

Most likely what is happening is that you are executing your script with an older version of node (more specifically V8) that had restrictions on how/where some ES6 features could be used. Upgrading node (at least to v4.0.0) should fix the problem.

mscdex
  • 104,356
  • 15
  • 192
  • 153
  • isnt the v0.12.18 the last version? – Pedro Gaspar Jun 07 '17 at 00:00
  • @PedroGaspar Nope. The latest long term supported NodeJS version is 6. See: https://nodejs.org/en/download/ – Samuel Toh Jun 07 '17 at 00:04
  • Jesus , this , can you help me giving command lines as i'm using vps , also do you recommend version 6 or 8 . – Pedro Gaspar Jun 07 '17 at 00:10
  • Node v8.x won't become an LTS branch until October. Node v6.x is currently the newest LTS branch. It's up to you to choose because there are multiple factors that come into play when deciding what branch to go with. – mscdex Jun 07 '17 at 01:17
1

Simply replace 'const' by 'var'. Strict mode forces you to declare your variables explicitely.

RaphaMex
  • 2,781
  • 1
  • 14
  • 30
  • Can you be more detailed? Change const by var in js file? – Pedro Gaspar Jun 07 '17 at 00:00
  • Exactly, change "const myVar = require(...)" by "var myVar = require(...)". As mscdex said, the "const myVar = " syntax is not supported by your version. Anyway, using const on an object reference only makes the reference const, not the object itself that can still be modified later on. – RaphaMex Jun 07 '17 at 00:38