Angular 9抛出未捕获的引用错误:regeneratorRuntime未定义。

4

我创建了一个新的Angular应用程序,将第三方应用程序(svgedit)通过将dist文件夹中的所有内容复制到Angular应用程序的资产文件夹中并在index.html中进行引用来导入。现在我遇到了这个错误:

Uncaught ReferenceError: regeneratorRuntime未定义

我已经搜索并看到了建议包括babel-polyfill等,但是还没有解决这个问题。

这是我的设置,Angular 9.1.7

软件包

@angular-devkit/architect         0.901.7
@angular-devkit/build-angular     0.901.7
@angular-devkit/build-optimizer   0.901.7
@angular-devkit/build-webpack     0.901.7 
@angular-devkit/core              9.1.7
@angular-devkit/schematics        9.1.7
@angular/cli                      9.1.7
@ngtools/webpack                  9.1.7
@schematics/angular               9.1.7
@schematics/update                0.901.7
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

package.json:

{
  "name": "scada",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/core": "~9.1.0",
    "@angular/forms": "~9.1.0",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    "@babel/polyfill": "^7.10.1",
    "jquery": "^3.5.1",
    "rxjs": "~6.5.4",
    "svgedit": "^5.1.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.0",
    "@angular/cli": "~9.1.0",
    "@angular/compiler-cli": "~9.1.0",
    "@angular/language-service": "~9.1.0",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
}
1个回答

6

在我的Angular应用程序中使用Contentful时,我遇到了相同的错误。您可以将以下代码添加到您的app.component中:

import "core-js/stable";
import "regenerator-runtime/runtime";

我在这里找到了它: https://github.com/zloirock/core-js#babelpolyfill

2
如果我将它放入polyfills而不是app.component中,它对我也有效。 - Tomasz GORKA
是的,这应该在 polyfills.ts 文件中。 - jaw

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接