0

I hav been trying to run the vue-electron app. But the following error comes.

  App threw an error during load
  C:\newFolder02\pos4-desktop\node_modules\@serialport\stream\lib\index.js:103
    const settings = { ...defaultSettings, ...options }
                       ^^^

  SyntaxError: Unexpected token ...
      at createScript (vm.js:74:10)
      at Object.runInThisContext (vm.js:116:10)
      at Module._compile (module.js:533:28)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:503:32)
      at tryModuleLoad (module.js:466:12)
      at Function.Module._load (module.js:458:3)
      at Module.require (module.js:513:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (C:\newFolder02\pos4-desktop\node_modules\serialport\lib\index.js:1:175)

The error comes from the following line.

const settings = { ...defaultSettings, ...options }

I use following tools

  • node 8.16.0
  • npm 6.4.1
  • electron 1.8.2

It doesn't work in Windows. But it works in Mac OS. Any idea..?

bhanuka.w
  • 13
  • 6
  • Your node environment doesn't support ES6 syntax which is supposed to be already included in node 8.16 – fodma1 Jan 30 '20 at 07:31
  • @fodma1 Yes. It is true. The development of the software started more than one years ago. Upgrading to the latest ones is the best solution. – bhanuka.w Jan 30 '20 at 08:04

1 Answers1

0

I have found a solution. You can convert the ES6 code to original JavaScript code with Babel(https://babeljs.io/en/repl).

I converted the ES6 code to vanilla JavaScript through Babel. I ticked ENV PRESET in left sidebar. I set Electron to "1.8" and Node to "8.16". It worked well. Babel Screenshot

bhanuka.w
  • 13
  • 6