当为生产而构建时,Angular 4应用程序将无法运行

Jam*_*ter 8 angular

我正在尝试部署我的第一个Angular 4应用程序而且我遇到了严重的问题.

每当我尝试加载应用程序时,我都会收到此错误:

SCRIPT5007: Unable to get property 'create' of undefined or null reference
vendor.8f08e50eff049f37e041.bundle.js (1,93870)
Run Code Online (Sandbox Code Playgroud)

我不知道如何调试这个.

要构建服务器,我运行了命令: ng build --prod

我也尝试过:ng server --prod这实际上给了我两次这个错误,以及上面的错误

SCRIPT5011: Can't execute code from a freed script
polyfills.3ae08eaf6129a55130cb.bundle.js (1,30944)
Run Code Online (Sandbox Code Playgroud)

编辑

我重新安装了Angular CLI并创建了一个新应用程序,我将旧代码(index.html和app文件)复制到新应用程序中并遇到同样的问题.

只是为了确定我创建了另一个应用程序,没有做任何更改并运行它.

我现在可以肯定地说我相信问题出现在我所制作的代码中.但是我不知道在哪里看,我已经(通过字面意思)搜索了我改变的每个文件,并且没有任何create属性.

有没有办法在不破坏代码的情况下构建我的应用程序以进行生产?

更新

我运行了ng build --prod --sourcemap=true命令,并在日志开始时收到此警告

The <template> element is deprecated. Use <ng-template> instead ("
[WARNING ->]<template [ngIf]="!isClosed">
  <div [class]="'alert alert-' + type" role="alert" [ngClass]="classes""): ng:///C:/Users/jamie/Desktop/play/node_modules/ngx-bootstrap/alert/alert.component.d.tsHash: 4607d21b2e5e9f27bd39
Run Code Online (Sandbox Code Playgroud)

可以弃用代码导致问题吗?

此外,在gamerfinder.net/dev上运行的构建是我从上面的命令获得的构建,我现在没有得到Unable to get property 'create'错误,而是我得到syntax error每个文件(您可以通过访问链接看到).

对于想要查看它的人,可以在GitHub上找到应用程序的整个代码.

Rob*_*hof 3

我安装了你的项目,但遇到了构建问题。CLI我通过更新到解决了这个问题1.2.7。这可能是因为您使用固定版本CLI但使用最新的角度版本而发生的。我建议你使用^1.2.7asCLI版本。

接下来我也遇到了和你一样的问题。这很容易解决。从您的中删除此行app.module.ts

platformBrowserDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)

它不应该在那里。

附言。你的代码有点乱。文件名中包含大写字母、忘记分号等。我建议您阅读样式指南并在 IDE 中使用 TSlint。