React-native-code-push: babelHelpers.asyncToGenerator is not a function

Created on 31 Mar 2016  Â·  6Comments  Â·  Source: microsoft/react-native-code-push

Hey — I'm on RN v0.21.0 using Code Push v1.10.0-beta, and as soon as I add the line import codePush from 'react-native-code-push'; into my project, I receive the error babelHelpers.asyncToGenerator is not a function. I found this issue which makes me think @brentvatne might know the solution per https://github.com/facebook/react-native/issues/4844. The contents of my .babelrc are as follows:

{
  "presets": [ "react-native", "stage-0" ],
  "plugins": [
    "transform-decorators-legacy",
    "transform-async-to-generator"
  ]
}

Most helpful comment

I resolved, here was my new .babelrc file:

{
  "presets": [ "react-native" ],
  "plugins": [
    "transform-decorators-legacy",
    "transform-do-expressions",
    "transform-function-bind",
    "transform-class-constructor-call",
    "transform-export-extensions",
    "syntax-trailing-function-commas",
    "transform-exponentiation-operator"
  ]
}

I also ran the packager with --reset-cache to work: node_modules/react-native/packager/packager.sh --reset-cache.

Thank you and also thanks to @skevy for help over Slack in ExponentJS.

All 6 comments

screen shot 2016-03-31 at 11 12 03 am

@niftylettuce This isn't a bug with CodePush, but rather, an issue with the packager when you use a custom Babelrc file. CodePush uses async/await and unfortunately this ends up causing issues, as you've seen with the linked bug. You would hit this issue if using any other library that uses async/await. The only solution that we've found it to either remove your custom babelrc or update the packager's Babel helpers file as mentioned in the RN bug you mentioned.

I resolved, here was my new .babelrc file:

{
  "presets": [ "react-native" ],
  "plugins": [
    "transform-decorators-legacy",
    "transform-do-expressions",
    "transform-function-bind",
    "transform-class-constructor-call",
    "transform-export-extensions",
    "syntax-trailing-function-commas",
    "transform-exponentiation-operator"
  ]
}

I also ran the packager with --reset-cache to work: node_modules/react-native/packager/packager.sh --reset-cache.

Thank you and also thanks to @skevy for help over Slack in ExponentJS.

For further information, see here: https://github.com/facebook/react-native/issues/4844#issuecomment-204035720

I found maybe is the watchman problem, I use the react 0.41.2, it occured this issue, because I install the stage-0, error, so uninstall it, but still. finally, I delete all the project and git clone again, error still their! but same project is good at my PC! so, watchman watch-del-all, rebuild, everything OK!
ultimate solution

brew uninstall watchman

@niftylettuce thanks, your solution works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-akhalkov picture sergey-akhalkov  Â·  4Comments

SudoPlz picture SudoPlz  Â·  4Comments

EdmundMai picture EdmundMai  Â·  4Comments

DeDuckProject picture DeDuckProject  Â·  3Comments

fanzhiri picture fanzhiri  Â·  3Comments