TransformError when running React Native Getting Started project (iOS)

前端 未结 4 882
攒了一身酷
攒了一身酷 2021-01-14 09:16

I\'m having trouble getting the React Native Getting Started project to run.

I followed this guide: https://facebook.github.io/react-native/docs/getting-started.html<

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 10:08

    It is caused by bug in babel-preset-react-native. Although solutions already provided here reinstall modules, package.json is still pointing to 3.0 of babel-preset-react-native and doesn't help you.

    To solve this problem, I think you need to update package.json to point babel-preset-react-native to 2.1.

    "dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.1",
    "babel-preset-react-native": "2.1.0"
    },
    

    See above, now babel-preset-react-native points to 2.1.0. Then,

    rm -rf node_module
    npm cache clean
    npm i
    

    And restart whichever android or ios. At least, this worked for me.

提交回复
热议问题