# Fix 'regeneratorRuntime is not defined' in Parcel

> How to fix the regeneratorRuntime is not defined error in Parcel by importing regenerator-runtime or adding a browserslist field to package.json.

Author: Flavio Copes | Published: 2020-05-08 | Canonical: https://flaviocopes.com/parcel-regeneratorruntime-not-defined/

I run into this problem in a project using [Babel](https://flaviocopes.com/babel/) as soon as I added an `async` function, but the problem is the same for any recent [JavaScript](https://flaviocopes.com/javascript/) feature:

![Browser developer tools console showing Uncaught ReferenceError: regeneratorRuntime is not defined error](https://flaviocopes.com/images/parcel-regeneratorruntime-not-defined/Screenshot_2020-04-05_at_17.45.59.png)

Babel, used by [Parcel](https://flaviocopes.com/parcel/), generates a polyfill, but to avoid this error you need to also load the `regenerator-runtime` runtime.

One solution: add to the top of your main JavaScript file:

```
import 'regenerator-runtime/runtime'
```

Parcel will include this package by default, increasing the size of 25KB.

The solution that is the most efficient in terms of codebase is adding the `browserslist` property to your package.json.

For example:

```json
"browserslist": [
  "last 1 Chrome version"
]
```

For testing is good enough. To support multiple browsers:

```json
"browserslist": [
  "last 3 and_chr versions",
  "last 3 chrome versions",
  "last 3 opera versions",
  "last 3 ios_saf versions",
  "last 3 safari versions"
]
```

or also:

```js
"browserslist": [
  "since 2017-06"
]
```

You have to add a version that's recent enough to support `async/await`, so Babel does not try to add a polyfill.

Check all the valid values here: <https://github.com/browserslist/browserslist>
