【问题标题】:React native new init app is not running on from xcode反应本机新的初始化应用程序没有从 xcode 上运行
【发布时间】:2021-09-12 14:03:34
【问题描述】:

React Native 新的初始化应用程序无法通过 xcode 或 npm run ios 运行。

  • 系统 - Mac
  • Npm - 6.14.12
  • 节点 - v14.16.1
  • react-native - 2.0.1
>>>>> Generating schema from flow types


/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/parsers/flow/index.js:220
    const regex = new RegExp(TURBO_MODULE_REGISTRY_REQUIRE_REGEX_STRING, 'g');
                  ^

SyntaxError: Invalid regular expression: /TurboModuleRegistry\s*\.\s*get(Enforcing)?\s*<\s*Spec\s*>\s*\(\s*['"](?<nativeModuleName>[A-Za-z$_0-9]+)['"]\s*,?\s*\)/: Invalid group
    at new RegExp (<anonymous>)
    at buildSchema (/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/parsers/flow/index.js:220:19)
    at Object.parseFile (/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/parsers/flow/index.js:276:10)
    at files.reduce (/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:75:35)
    at Array.reduce (<anonymous>)
    at combineSchemas (/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:66:16)
    at Object.<anonymous> (/Users/admin/Documents/ios/MyProject/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:90:40)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
Command PhaseScriptExecution failed with a nonzero exit code

【问题讨论】:

    标签: node.js xcode macos react-native npm


    【解决方案1】:

    这是react-native 中的react-native-codegen 引用设置为v0.0.6 的问题。在较新的0.0.7 版本中,解析器发生了很大变化。看起来早在 2021 年 2 月,reference 已更新为 0.0.7,这也是 react-native@0.65.0 的一部分。

    如果您查看 react-native 包中的 package.json 文件,我猜它引用了 codegen 包的 0.0.6 版本。您可以更新 react-native(我看到您在帖子中将其引用为 2.0.1,但请检查 react-native 文件夹中的 package.json 文件以查看您拥有的内容)。你也可以像这样添加新版本的codegen:

    npm install --save-dev react-native-codegen@0.0.7

    如果可以的话,我建议更新 react-native,但是根 package.json 中的 codegen 包更新现在也有效。

    【讨论】:

      猜你喜欢
      • 2020-12-06
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-17
      • 2022-12-07
      • 1970-01-01
      相关资源
      最近更新 更多