regeneratorRuntime is not defined NextJS
See original GitHub issueIssue
Build fails in nextjs due to regernatorRuntime is not defined from RecognitionManger.js. This is because the babel config which bundles the package isn’t conducive to eliminating regernatorRuntime which doesn’t work in server side rendering (SSR , which is what NextJS package specializes in).
Hacky Solution
I don’t know the solution, but my hacky solution was to copy the code from src into my repo and let the nextJS babel config ‘next/babel’ do the compilation without error. I tried https://github.com/babel/babel/issues/8829#issuecomment-456524916 but it did not solve the problem.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Next App - ReferenceError: regeneratorRuntime is not defined ...
Current Behavior Migrated from 11.4.0 to 11.5.1 When building a NextJS app, a RegeneratorRuntime error is thrown and the app will not build....
Read more >How to fix regeneratorRuntime is not defined?
I'm using next.js. I just installed the dependency regenerator-runtime and added import 'regenerator-runtime/runtime'; to the top of the ...
Read more >regeneratorRuntime is not defined in React - Stack Overflow
I'm getting an error "Uncaught ReferenceError: regeneratorRuntime is not defined". Please help me to find out the error and how to resolve ...
Read more >Uncaught ReferenceError: regeneratorRuntime is not defined ...
The solution I found (inspired by https://stephencharlesweiss.com/regenerator-runtime-not-defined/) was to import the @babel/plugin-transform-runtime NPM ...
Read more >Parcel, how to fix the `regeneratorRuntime is not defined` error
Parcel, how to fix the `regeneratorRuntime is not defined` error ... HTML, CSS, JS, Tailwind, React, Next.js and much more! ✨.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I think
import 'regenerator-runtime/runtime'didn’t work anymoreEdit: In my case now it works if it imported in
_app.jsinstead ofindex.jsThanks for taking the time to prepare that example repo. I was able to reproduce the issue according to your instructions.
The solution that worked for me was to follow what others have done:
npm i --save regenerator-runtimeimport 'regenerator-runtime/runtime'at the top of this fileI also tried installing the Babel runtime and transform plugin, plus the following
.babelrcfile:No change in result with that approach - not entirely sure why as I believe NextJS honours the root Babel config.
Anyway, I hope the manual import solution above is sufficient for you. I’m debating whether to add the Babel runtime as a peer dependency for this library - still researching the consequences of that.