【问题标题】:how to fix syntaxeror when start yarn启动纱线时如何修复语法分析器
【发布时间】:2019-04-02 14:23:42
【问题描述】:

我是 React 初学者,在 atom 中启动 yarn 时出现语法错误。

我在第一次启动 yarn 之前没有编辑任何代码,但它有语法错误。我已在本地终端中使用 nvm 和 yarn 成功运行 create-react-app

这是原子终端的错误日志

question Which command would you like to run?: start
$ react-scripts start
/Users/hyerimhyeon/react-tutorials/contact-app/node_modules/react-dev-utils/WebpackDevServerUtils.js:166
  compiler.hooks.done.tap('done', async stats => {
                                  ^^^^^
SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hyerimhyeon/react-tutorials/contact-app/node_modules/react-scripts/scripts/start.js:45:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我该如何解决?

【问题讨论】:

  • 您不能以这种方式将async 应用于箭头函数。检查这个答案:stackoverflow.com/a/42964310/751484
  • @JonathanM 这不正确。 syntax is fine 用于带有单个参数的 async 箭头函数。相反,错误消息表明 OP 正在运行根本不支持 async/await 的旧版本的 Node。

标签: javascript reactjs atom-editor yarnpkg nvm


【解决方案1】:

将您的节点版本更新到至少 v8,它应该可以完美运行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 2019-08-03
    • 1970-01-01
    • 2021-10-08
    • 2016-05-13
    • 1970-01-01
    • 2013-01-01
    相关资源
    最近更新 更多