“babelHelpers.asyncToGenerator is not a function”

2019-07-11 07:30发布

问题:

I updated React-Native from 0.14.0 to 0.16.0 and from now, I have errors at runtime:

Here are the npm dependencies:

"dependencies": {
  "async": "^1.5.0",
  "immutable": "^3.7.6",
  "react-native": "^0.16.0",
  "react-native-contacts": "../../react-native-contacts",
  "react-native-contacts-rx": "^1.0.1",
  "react-native-gifted-messenger": "0.0.7",
  "react-native-i18n": "0.0.6",
  "react-redux": "^4.0.1",
  "redux": "^3.0.5",
  "rx": "^4.0.7"
},
"devDependencies": {
  "babel-eslint": "^5.0.0-beta6",
  "eslint": "^1.10.3",
  "eslint-config-airbnb": "^2.1.1",
  "eslint-plugin-react": "^3.11.3",
  "events": "^1.1.0",
  "flux": "^2.1.1",
  "keymirror": "^0.1.1",
  "lodash": "^3.10.1",
  "redux-devtools": "^3.0.0"
}

And my .babelrc file:

{
  "retainLines": true,
  "compact": true,
  "comments": false,
}

Any suggestions?

回答1:

The Questions was answered in an issue @Jean Lebrument submitted. Positing answer here for stumblers like myself...

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

The problem is most likely in your .babelrc file. If you experience this problem, compare your .babelrc file to react natives default one. Try removing the file or building off of default one, adding the features that you need.

Make sure to restart your packager, stop, and re-run your project.



回答2:

I had this exact same problem you can check out what I did here - https://stackoverflow.com/a/53069785/2884655

But in short I just imported the babel-plugin-transform-async-to-generator module into my project and added it into my babelrc file