【发布时间】: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