0

我一直在尝试运行 vue-electron 应用程序。但是出现以下错误。

  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)

错误来自以下行。

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

我使用以下工具

  • 节点 8.16.0
  • npm 6.4.1
  • 电子 1.8.2

它在 Windows 中不起作用。但它适用于 Mac OS。任何想法..?

4

1 回答 1

0

我找到了解决方案。您可以使用 Babel( https://babeljs.io/en/repl )将 ES6 代码转换为原始 JavaScript 代码。

我通过 Babel 将 ES6 代码转换为原生 JavaScript。我在左侧边栏中勾选了 ENV PRESET。我将 Electron 设置为“1.8”,将 Node 设置为“8.16”。它运作良好。 通天塔截图

于 2020-01-30T08:55:02.763 回答