【发布时间】:2019-02-21 17:54:20
【问题描述】:
我们有一个包含 POJavascript、原型、jquery 的旧版应用程序。
我们正在一次一个地重写应用程序。 目前我们已经用 angular4 重写了一些部分。我们正在使用 webpack 捆绑 angular4 应用程序,包括应用程序登录页面中的 Angular 捆绑包,效果很好; webpack 开发服务器也运行良好。
现在,我正在尝试升级到 angular CLI 和 angular v6.2.1。所以,我用 CLI 创建了一个新项目,然后将我的 angular4 源代码复制到这个新项目中,解决了所有错误。 CLI 正在吐出所有必需的脚本。我将这些脚本包含在我的登录页面中。
使用 prod build 它不会在控制台中显示任何错误,并且不会加载 Angular 应用程序。我尝试使用 ng serve,在登录页面中包含 https://localhost:4200/xxx 脚本,它在控制台中显示以下错误...
注意:如果直接访问(https://localhost:4200)而没有任何错误,则Angular App可以工作;但是我需要通过我的旧应用程序的登录页面来访问它,因为许多其他的东西都被初始化了,我们需要部分地发布。我认为这与区域有关,但无法弄清楚确切的问题。
Error: No ErrorHandler. Is platform module (BrowserModule) included?
Stack trace:
["./node_modules/@angular/core/fesm5/core.js"]/PlatformRef.prototype.bootstrapModuleFactory/<@https://localhost:4200/vendor.js:43138:23 [angular]
forkInnerZoneWithAngularBehavior/zone._inner<.onInvoke@https://localhost:4200/vendor.js:42646:24 [angular]
["./node_modules/@angular/core/fesm5/core.js"]/NgZone.prototype.run@https://localhost:4200/vendor.js:42560:16 [<root>]
["./node_modules/@angular/core/fesm5/core.js"]/PlatformRef.prototype.bootstrapModuleFactory@https://localhost:4200/vendor.js:43133:16 [<root>]
["./node_modules/@angular/core/fesm5/core.js"]/PlatformRef.prototype.bootstrapModule/<@https://localhost:4200/vendor.js:43175:53 [<root>]
scheduleResolveOrReject/<@https://localhost:4200/polyfills.js:3194:29 [<root>]
drainMicroTaskQueue@https://localhost:4200/polyfills.js:2917:25 [<root>]
["./node_modules/zone.js/dist/zone.js"]/</ZoneTask.invokeTask@https://localhost:4200/polyfills.js:2822:21 [<root>]
patchEventTarget/invokeTask@https://localhost:4200/polyfills.js:3862:9 [<root>]
patchEventTarget/globalZoneAwareCallback@https://localhost:4200/polyfills.js:3888:17 [<root>]
【问题讨论】:
-
您确定正在导入 BrowserModule 吗?类似问题stackoverflow.com/questions/45256839/…
-
我不确定您在关于
/xxx路线的部分中所说的内容。你能详细说明一下吗? -
BrowserModule 包括在内,我已经参考了所有类似的问题。
-
/xxx 表示我包含所有角度脚本,即localhost:4200/runtime.js、polyfills.js、styles.js、vendor.js 和 main.js
标签: javascript angular webpack prototypejs