未定义符号错误_包裹,如何修复“ regeneratorRuntime未定义”错误

未定义符号错误

I run into this problem in a project using Babel as soon as I added an async function, but the problem is the same for any recent JavaScript feature:

添加async功能后,我立即在使用Babel的项目中遇到了这个问题,但是最近的任何JavaScript功能都存在相同的问题:

Babel, used by Parcel, generates a polyfill, but to avoid this error you need to also load the regenerator-runtime runtime.

Parcel使用的Babel生成一个polyfill,但是要避免此错误,您还需要加载regenerator-runtime运行时。

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

一种解决方案:添加到主JavaScript文件的顶部:

import 'regenerator-runtime/runtime'

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

默认情况下,Parcel将包括此软件包,增加25KB的大小。

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

就代码库而言,最有效的解决方案是将browserslist属性添加到package.json。

For example:

例如:

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

For testing is good enough. To support multiple browsers:

对于测试已经足够了。 要支持多种浏览器:

"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:

或者:

"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.

您必须添加最新的版本以支持async/await ,因此Babel不会尝试添加polyfill。

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

在此处检查所有有效值: https : //github.com/browserslist/browserslist

翻译自: https://flaviocopes.com/parcel-regeneratorruntime-not-defined/

未定义符号错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值