【问题标题】:Angular requires Zone.js polyfill. with system js i am facing this issueAngular 需要 Zone.js polyfill。使用系统js我面临这个问题
【发布时间】:2018-07-28 23:46:23
【问题描述】:

当我使用 systemjs 和 ASP.NET MVC4 安装 angular4 时,我遇到了这个错误。 我试图通过注释代码来解决这个问题

"throw new error('Angular requires Zone.js prolyfill.')" 

在 node_modules/@angular/core/core.umd.js 中。但没有任何结果。

我的确切问题是。

未捕获(承诺)错误:Angular 需要 Zone.js prolyfill。 在新的 NgZone (core.umd.js:3805) 在 PlatformRef__._bootstrapModuleFactoryWithZone (core.umd.js:4524) 在评估(core.umd.js:4569) 在

如果有人知道如何解决此问题,请帮助我。

我在我的 cshtml 文件中使用的依赖项

<script src="~/node_modules/core-js/client/shim.min.js"></script>
<script src="~/node_modules/zone.js@0.8.4/dist/zone.js"></script>
<script src="~/node_modules/reflect-metadata/Reflect.js"></script>
<script src="~/node_modules/systemjs/dist/system.src.js"></script>

<script src="~/systemjs.config.js"></script>
<script>
    System.import('app').catch(function (err)
    {
       console.error(err);
    });
</script>

【问题讨论】:

    标签: javascript angular systemjs


    【解决方案1】:

    使用来自node_modules 的版本号仔细检查该路径。它可能在文件结构中物理上不包含该版本号,并且未加载导致错误。直接验证,但是正确的路径应该如下:

    <script src="~/node_modules/zone.js/dist/zone.js"></script>
    

    如果您需要管理版本,您可以通过package.jsonnpm install 进行管理,如下所示:

    "zone.js": "0.8.4"
    

    【讨论】:

      猜你喜欢
      • 2015-04-01
      • 2020-07-25
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 2021-05-28
      • 2022-07-04
      • 1970-01-01
      相关资源
      最近更新 更多