Tag Archives: Parcel Service Error

[Solved] Parcel Service Error: regeneratorRuntime is not defined

When using the Parcelfront-end packaging tool to start the local service, the consoleconsole reports an error: Uncaught ReferenceError: regeneratorRuntime is not defined, according to the information: regeneratorRuntimeit is a global auxiliary function generated by the packaging tool, which is babelgenerated and is used for compatible async/awaitsyntax, so you need to configure the corresponding babelplugin.

Front-end engineering Parcel

First, configure babel

There are two ways to configure the babelplugin :

1. Create a separate configuration file .babelrc.

Under the windowsystem, a file whose name starts with . cannot be generated directly, but it can be generated by using the command echo on the cmd command line. The operation is as follows:

echo > .babelrc

Edit the .babelrcfile and configure it as follows:

{  "plugins": [    '@babel/plugin-transform-runtime'  ]}

2. Configure babelin package.json

"babel": {  "plugins": [    '@babel/plugin-transform-runtime'  ]}

After the configuration is successful, restart the service, and Parcelthe dependencies will be downloaded and installed automatically, without manual operation npm install, which is really friendly.

2. Summary

Note: package.json higher than .babelrcthe weight.

If the project is not too complicated, it is highly recommended to use Parcelto build web applications, which is absolutely worry-free, convenient and fast.