New react-native app has 'TypeError: babelHelpers.typeof is not a function' [iOS]

后端 未结 7 1931
花落未央
花落未央 2020-12-31 02:37

A new project created with the latest version of react-native throws javascript error while running(/debugging). Tested this on simulator.

[fatal][tid:main]         


        
7条回答
  •  误落风尘
    2020-12-31 03:10

    Here's a comment explaining the issue:

    https://github.com/facebook/react-native/issues/4844#issuecomment-204035720

    To summarize:

    Babel presets 'stage-0' through 'stage-3' contain 'async-to-generator', which is not not necessary for react-native itself.

    The solution is to use the unofficial babel preset 'react-native-stage-0'

    Example:

    npm install babel-preset-react-native-stage-0 --save-dev
    

    .babelrc

    {
      "presets": ["react-native-stage-0"]
    }
    

    or with decorator support

    {
      "presets": ["react-native-stage-0/decorator-support"]
    }
    

    Empty cache and Restart

    watchman watch-del-all
    
    ./node_modules/react-native/packager/packager.sh start --reset-cache
    

提交回复
热议问题