Suddenly seeing error “Plugin/Preset files are not allowed to export objects, only functions” in create-react-native-app project

丶灬走出姿态 提交于 2019-12-04 23:55:09

Found that the problem is this:

At some point, must have done a npm update which updated react-native to 0.56 and expo to 28.0.0.

Looking at the react-native docs (https://facebook.github.io/react-native/docs/upgrading.html#create-react-native-app-projects), react-native seems to require installing versions of react-native, react, and expo that are all specifically compatible with each other. A matrix of which versions of which packages are compatible with each other can be found here: https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md and says

Each version of these dependencies is only compatible with a narrow version range of the other two.

As of this writing the document was last updated on April 27, 2018, so it is not exactly clear what versions of react and expo (which has recently released version 28.0.0) should be used in combination with the now-out react-native@0.56. The most recent react-native version that is documented is react-native@0.55 (to go with react@16.3.1 and expo@27.0.0), which I think is why downgrading to react-native@0.55 was helpful in this case (I don't know why there is no documentation in the matrix for react-native@0.56 yet), my package.json now looking like:

...
"dependencies": {
    "@expo/vector-icons": "^6.3.1",
    "eslint": "^4.19.1",
    "expo": "^27.1.0",
    "prop-types": "^15.6.2",
    "react": "16.3.1",
    "react-native": "^0.55.4",
    "react-native-mail": "^3.0.6",
    "react-native-modal-dropdown": "^0.6.2",
    "react-navigation": "^2.6.2",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "tcomb-form-native": "^0.6.14",
    "uuid": "^3.3.2"
  }
}

Same issue happened with me today. Apparently, react-native was upgraded to 0.56.0. Downgraded react-native version back to 0.55.0 solved my issue

npm install react-native@0.55.0

The reason was fully explained by @lampShadesDrifter, however I will add a quicker solution which is to use react-native sdk bundled from expo: https://github.com/expo/react-native/

So you may add this your dependencies with expo sdk 29:

"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!