I have ran into a problem, the error is
regeneratorRuntime is not defined while working with React and Parcel bundler.
The problem appeared after I added an async function and while searching the problem, I found a stack-overflow solution but it didn't work. So, don't use this method.
First, I found this solution:
import "babel-polyfill";at the top of the file that you are using the async function.
later learned that babel-polyfill is deprecated. So, to solve the regeneratorRuntime problem, do this:
npm install --save regenerator-runtime
Update webpack file
entry: ["regenerator-runtime/runtime.js", "<your enter js file>"]
import 'regenerator-runtime/runtime'at the top of the file that you're using async function
I didn't edit webpack, because I'm using Parcel, but just importing regenerator-runtime/runtime at the top of the file solved the problem.
BABEL/ReferenceError regeneratorRuntime is not defined #9849
Oldest comments (21)
thanks man u saved my keyboard from being smashed
Haha, good for the keyboard 😃
Thank you soooo much!!! You saved me!
Happy to help 👍
Hi, now am getting a 'process not defined' error because in my file am using 'process.env.API_URL' to create a base url to the server. How can I solve this? Thanks
I created an account just to thank you!
thank you so much!
Wow, thanks Pedro 👍🏻
Made an account just to say non of these or any single findable "fix" on the internet can fix this in late 2021,
again webpack and babel waste hours upon hours of dev time for their chronic incompatibly and version inconsistency.
I hate every hour I work in this industry.
then please leave to code
Strange, worked for me.
[Already Solved] Babel ReferenceError: regeneratorRuntime is not defined
Thanks, work for me 😍
ty my man this works, i use the simple solution 3
Thanks for saving my keyboard from getting shattered, guy.
babel-polyfillin couple of files in codebase but was not able to understand since I was new. In those files it had just this statement to fix issue:
Thanks for this article..!
Thank you 🧡
Thank you so much Hulya, it worked for me.
This is no more recommended. Use this instead:
...and add in .babelrc:
Thank you it solved my async/await issue 🙌🏼
wow! It, weirdly enough...worked!
Usually I too waste HOURS looking for how to fix this rocket science configs.
I have components that are lazy loaded with all their dependencies, but when a component imported something from node_modules, I had this error.
I'm using next.js.
I just installed the dependency
import 'regenerator-runtime/runtime';to the top of the root component that was lazy loaded and it, for my surprise, worked, as simple as that!
Thank you very much :)
Simple and effective.
This answer helped me => stackoverflow.com/questions/654870...