React native new init app is not running on from xcode

Viewed 341

React Native new init app not able to run via xcode or via npm run ios.

  • System - Mac
  • Npm - 6.14.12
  • node - 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
1 Answers

This was an issue where the react-native-codegen reference in react-native was set to v0.0.6. In the newer 0.0.7 version a lot changed in the parser. It looks like back in February of 2021 the reference was updated to 0.0.7 which is also a part of react-native@0.65.0.

If you check out the package.json file in the react-native package I am guessing it is referencing the 0.0.6 version of the codegen package. You could update react-native (I see you referenced it as 2.0.1 in your post, but check the package.json file in the react-native folder to see what you have). You can also add the new version of codegen like this:

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

I recommend updating react-native if you can, but the codegen package update just in the root package.json also works for now.

Related