When using the Parcel
front-end packaging tool to start the local service, the console
console reports an error: Uncaught ReferenceError: regeneratorRuntime is not defined
, according to the information: regeneratorRuntime
it is a global auxiliary function generated by the packaging tool, which is babel
generated and is used for compatible async/await
syntax, so you need to configure the corresponding babel
plugin.
First, configure babel
There are two ways to configure the babel
plugin :
1. Create a separate configuration file .babelrc
.
Under the window
system, 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 .babelrc
file and configure it as follows:
{ "plugins": [ '@babel/plugin-transform-runtime' ]}
2. Configure babel
in package.json
"babel": { "plugins": [ '@babel/plugin-transform-runtime' ]}
After the configuration is successful, restart the service, and Parcel
the dependencies will be downloaded and installed automatically, without manual operation npm install
, which is really friendly.
2. Summary
Note: package.json
higher than .babelrc
the weight.
If the project is not too complicated, it is highly recommended to use Parcel
to build web applications, which is absolutely worry-free, convenient and fast.