【问题标题】:Launch yarn run script launch error whereas pure command is working (React Native Project)在纯命令工作时启动纱线运行脚本启动错误(React Native Project)
【发布时间】:2019-12-16 12:40:44
【问题描述】:

我在 package.json 中添加了一个脚本命令,如下所示:

"ios": "sh config.sh && react-native run-ios"

当我没有纱线时,这个命令工作正常。

但是当我尝试 with yarn (yarn run iosyarn ios) 执行它时...该命令执行得很好但是Metro bundler 因给定错误而失败:

/Users/ano/mols/node_modules/@react-native-community/cli/build/index.js:154
  const cmd = _commander().default.command(command.name).action(async function handleAction(...args) {
                                                                ^^^^^

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/ano/mols/node_modules/react-native/cli.js:13:11)
Process terminated. Press <enter> to close the window

有谁知道发生了什么? 谢谢。

【问题讨论】:

    标签: react-native yarnpkg metro-bundler


    【解决方案1】:

    可能您的 NodeJS 版本太旧,不支持 async/await 功能。语法错误是由于 Javascript 解释器无法识别异步令牌并对参数感到困惑,请将您的 nodejs 版本更新为最新的 LTS。

    【讨论】:

      猜你喜欢
      • 2019-06-20
      • 2022-06-20
      • 1970-01-01
      • 2021-09-04
      • 2020-01-10
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多