Common Errors: regeneratorRuntime is not defined

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


When using async/await or other modern JavaScript features with build tools like Parcel or older Babel configurations, you might see:

ReferenceError: regeneratorRuntime is not defined

Why it happens

Babel transpiles modern JavaScript (like async/await) into older JavaScript that can run in older browsers. For async/await, it uses a library called regenerator-runtime to polyfill generators.

The error occurs when Babel transforms your code but the runtime isn’t available.

Solution 1: Import the runtime

Add this import at the top of your main JavaScript file:

import 'regenerator-runtime/runtime'

This adds about 25KB to your bundle size.

The better solution is to tell your build tool which browsers you’re targeting. If your target browsers already support async/await, Babel won’t transform it and you won’t need the polyfill.

Add a browserslist property to your package.json:

{
  "browserslist": [
    "last 1 Chrome version"
  ]
}

For development/testing, this is sufficient. For production, you might want broader support:

{
  "browserslist": [
    "last 3 and_chr versions",
    "last 3 chrome versions",
    "last 3 opera versions",
    "last 3 ios_saf versions",
    "last 3 safari versions"
  ]
}

Or use a date-based approach:

{
  "browserslist": [
    "since 2017-06"
  ]
}

The key is to specify browsers recent enough to support async/await natively (roughly browsers from 2017 onwards).

Checking browser support

You can see all valid browserslist values at: https://github.com/browserslist/browserslist

To see what browsers your query matches:

npx browserslist

Modern alternatives

If you’re starting a new project, consider using more modern build tools like:

  • Vite: Uses native ES modules in development and esbuild for production
  • esbuild: Extremely fast bundler that handles modern JavaScript well
  • Bun: JavaScript runtime with built-in bundler

These tools typically handle modern JavaScript features without requiring runtime polyfills for reasonably modern browsers.

Lessons in this unit:

0: Introduction
1: "X is not a function" errors
2: "document is not defined" error
3: Cannot assign to read only property
4: Parse failure: Unterminated string constant
5: FormData multipart fetch issues
6: ▶︎ regeneratorRuntime is not defined
7: Unexpected identifier in modules
8: Unterminated string literal