Create React Native App. - Plugin/Preset files are not allowed to export objects, only functions

前端 未结 4 1312
抹茶落季
抹茶落季 2021-01-18 03:19

Need some help, I\'m getting a weird error out of left field that I have not been able to debug. This project was bundling successfully until yesterday after I setup my reac

4条回答
  •  Happy的楠姐
    2021-01-18 03:57

    My app is ejected and fagerbua's answer helped but I had to struggle a bit further to get it to work. I eventually started a fresh create-react-native-app, ejecting, and edited my package.json and .babelrc to use babel-preset-react-native, the 0.56.0 version of react-native, and the 16.4.1 version of react. I also had to remove the transform-react-jsx-source plugin from the .babelrc file. Below are the files used for a minimal working react-native@0.56.0 app:

    .babelrc file:

    {
      "presets": [
        "babel-preset-react-native"
      ]
    }
    

    package.json:

    {
      "name": "myapp",
      "version": "0.1.0",
      "private": true,
      "devDependencies": {
        "babel-preset-react-native": "^5",
        "jest": "^23.4.2",
        "jest-react-native": "^18.0.0",
        "react-test-renderer": "16.3.1"
      },
      "scripts": {
        "start": "react-native start",
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "test": "jest"
      },
      "jest": {
        "preset": "react-native"
      },
      "dependencies": {
        "react": "^16.4.1",
        "react-native": "^0.56.0"
      }
    }
    

    Once I got this working with the basic app, I copied these changes back into my main app, removed my node_modules folder, did npm install and everything just worked. I'm not sure if the updated jest version was needed, I don't use jest but it was automatically added on create.

提交回复
热议问题