-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"babelHelpers.asyncToGenerator is not a function" on React-Native 0.16.0 and 0.17.0 #4844
Comments
Hey JeanLebrument, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
Try clearing the package cache may be? rm -rf $TMPDIR/react* |
+1 same issue here
|
@JeanLebrument i remove my own don't know why but works. |
Thanks for your answer @filod but I need to use the preset stage-0 for my project. |
@JeanLebrument All transforms in |
@satya164 - I don't think that is the case actually, it uses these plugins by default: https://github.com/facebook/react-native/blob/master/packager/react-packager/.babelrc Your babelrc doesn't have any plugins or presets enabled, and babel6 doesn't enable any by default. You'll need to add those to your babelrc :) |
@brentvatne Oh, I mistakenly said stage-0. |
@brentvatne answer is out of date for anyone stumbling here: https://github.com/facebook/react-native/blob/e6cb02d61af82832016bafb259a1b0d3039a357e/babel-preset/README.md babel-preset-react-native is the preferred way to integrate your own babelrc |
Even with |
The same for me ! The following example doesn't work for me in React Native : https://goo.gl/0JEOwJ.
I remove my own babelrc in root dir, then everything goes alright ! But it seems impossible to use custom babelrc. |
So, it appears that the RN packager has its own implementation of |
@nevir - is there no way to use stage-0 async functions in react-native, then? |
I'll leave the same comment here from: este/este#662 (comment) It appears you can modify the react-native helpers file to (maybe?) fix this issue. Replace the helpers you find at /node_modules/react-native/packager/react-packager/src/Resolver/polyfills/babelHelpers.js (https://github.com/facebook/react-native/blob/master/packager/react-packager/src/Resolver/polyfills/babelHelpers.js) with the ones either generated yourself (how to: http://stackoverflow.com/questions/33703919/how-to-use-babel-6-external-helpers-in-the-browser) or from this code snippet:
|
👍 It worked for me but when this will be a permanent fix? Do we need to wait next version of react (i.e 0.21)? Thanks, |
@brentvatne can you investigate #4844 (comment) and #4844 (comment) Not sure if there is an issue or this belongs somewhere else, but it seems something is causing issues with the babel helpers. |
Hey ya'all... Sorry for the lack of response on this issue. I want to explain a little bit about how the babel-preset works and why this error happens. Babel is a complex beast. There are certain transforms that require "helpers" (contained in either babel-runtime, or included babelHelpers). React Native includes it's own set of helpers, and it does this in order to improve startup performance (see the blog post that talks about it here: https://code.facebook.com/posts/895897210527114/dive-into-react-native-performance/ and the commit here: b90fe8e). Important takeway -- lacking certain babel helpers is not an issue, it's a feature :) This is perf impact is super important...but unfortunately, it makes the Babel setup a bit more complex than what you'd read in the Babel documentation where you can just throw
into your .babelrc and get the latest and greatest JS features. That's why we created the preset...it makes it easy for people to get started with a custom babelrc. Unfortunately, the stage-3 babel preset contains "async-to-generator", which transforms In addition, it's important to note that
However, being a group of developers who love to live on the cutting edge, we want to use all of the stage-0 features! A babelrc that would accomplish that goal would look like this:
Note that it omits I've gone ahead and packaged this up into ANOTHER, unofficial babel-preset, called To use, simply
in your .babelrc. If you want experimental decorator support (provided by
in your .babelrc instead. Hope this helps everyone! P.S.: Make sure when you change your babelrc, you clear watchman and packager caches for good measure:
|
I got the same issue 'undefined is not a function (evaluating 'babelHelpers.asyncToGenerator') something doessnt compile without 'DEV' mode. but with the developer mode it doess'nt seem to have any issues. (Which makes debugging rather hard.) EDIT: Appearantly its not yet included in react-native v0.26 without some adaptations to the .babelrc file: Example:
.babelrc
or with decorator support (not yet needed myself)
Empty cache and Restart
|
Summary: We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](#5747 (comment)) led to [this comment](#4844 (comment)) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes #11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
Anyone knows how to get async generators/iterators working? I added plugin |
Summary: We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes facebook#11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
Summary: We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes facebook#11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
Summary: We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes facebook#11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
rm -rf $TMPDIR/react* |
It worked for me, here is the link |
Summary: We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook/react-native#5747 (comment)) led to [this comment](facebook/react-native#4844 (comment)) which contains a solution we've been using successfully in our production app. Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize). An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me. Closes facebook/react-native#11093 Differential Revision: D4353977 fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
None of the above worked for me, but it was an issue to do with something, somewhere in the cache. I resolved the issue by running react-native start --reset-cache |
I can't help but find the solutions posted here not really helpful If babel's mechanisms are broken on purpose to achieve better performance, fine - but I'd expect an alternative "react-native way of adding my own presets or plugins" Right now, we are failing to get rid of the error described in #4831 |
I ran into this issue and the only way to solve it was to delete my RN 0.43.2 |
@liuliangsir I tried many ways, on the end, your suggestion solved my problem, Thanks |
楼上竟然和我的偶像同名,还以为偶像也来写前端了 |
@jcollum Thanks! this solution work for me |
@honeyjie please use english to comment, because this is a matter of basic politeness |
@liuliangsir You are right, Thanks for your reminder |
Nothing from here helped me so I made a workaround which seems to work with no problem: Then, somewhere in your app:
P.S.: what caused the problem was some library which I had installed. Changing .babelrc in that lib as described above also solved the problem |
For me, When I remove |
This happened to me in the released apk but not in the development environment. Any ideas? |
I find solution microsoft/react-native-code-push#271. Answer niftylettuce |
Hello,
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
:And my
.babelrc
file:Any suggestions?
The text was updated successfully, but these errors were encountered: