Angular 5 --prod在浏览器中失败, - 但没有

时间:2018-01-16 07:13:49

标签: angular angular-cli firebase-hosting

我正在使用Angular 5开发一个Web应用程序。使用ng serve它在我的localhost:4200中呈现完美。当我运行ng serve --prod时,我的浏览器不会加载任何内容并抛出此错误:

    ERROR TypeError: Cannot read property 'OVERWRITE' of undefined
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1149086)
    at e.applyServerOverwrite (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:129317)
    at e.updateInfo_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1171422)
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1169637)
    at e.createRepo (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1533)
    at e.databaseFromApp (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:975)
    at Object.t.INTERNAL.registerService.Reference [as database] (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1209912)
    at e._getService (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:641580)
    at e.s.(anonymous function) [as database] (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:643503)
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:664222)
Oe @ main.03f1154228018f30c0ac.bundle.js:1
e.handleError @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.runOutsideAngular @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvoke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvokeTask @ main.03f1154228018f30c0ac.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
v @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
Promise resolved (async)
d @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onScheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleMicroTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
P @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.then @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.appInitializer @ main.03f1154228018f30c0ac.bundle.js:1
e.runInitializers @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvoke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.run @ main.03f1154228018f30c0ac.bundle.js:1
e.bootstrapModuleFactory @ main.03f1154228018f30c0ac.bundle.js:1
cDNt @ main.03f1154228018f30c0ac.bundle.js:1
o @ inline.e029292f71a17d803f23.bundle.js:1
0 @ main.03f1154228018f30c0ac.bundle.js:1
o @ inline.e029292f71a17d803f23.bundle.js:1
window.webpackJsonp @ inline.e029292f71a17d803f23.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
main.03f1154228018f30c0ac.bundle.js:1 TypeError: Cannot read property 'OVERWRITE' of undefined
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1149086)
    at e.applyServerOverwrite (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:129317)
    at e.updateInfo_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1171422)
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1169637)
    at e.createRepo (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1533)
    at e.databaseFromApp (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:975)
    at Object.t.INTERNAL.registerService.Reference [as database] (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1209912)
    at e._getService (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:641580)
    at e.s.(anonymous function) [as database] (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:643503)
    at new e (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:664222)
main.03f1154228018f30c0ac.bundle.js:1 ERROR TypeError: Cannot read property 'OVERWRITE' of undefined
    at new e (main.03f1154228018f30c0ac.bundle.js:1)
    at e.applyServerOverwrite (main.03f1154228018f30c0ac.bundle.js:1)
    at e.updateInfo_ (main.03f1154228018f30c0ac.bundle.js:1)
    at main.03f1154228018f30c0ac.bundle.js:1
    at main.03f1154228018f30c0ac.bundle.js:1
    at Object.t.forEach (main.03f1154228018f30c0ac.bundle.js:1)
    at Object.F1yO.t.each (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onServerInfoUpdate_ (main.03f1154228018f30c0ac.bundle.js:1)
    at t.handleTimestamp_ (main.03f1154228018f30c0ac.bundle.js:1)
    at t.onReady_ (main.03f1154228018f30c0ac.bundle.js:1)
Oe @ main.03f1154228018f30c0ac.bundle.js:1
e.handleError @ main.03f1154228018f30c0ac.bundle.js:1
next @ main.03f1154228018f30c0ac.bundle.js:1
t.object.i @ main.03f1154228018f30c0ac.bundle.js:1
t.__tryOrUnsub @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t._next @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t.emit @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.runOutsideAngular @ main.03f1154228018f30c0ac.bundle.js:1
onHandleError @ main.03f1154228018f30c0ac.bundle.js:1
e.handleError @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
_ @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
k @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
main.03f1154228018f30c0ac.bundle.js:1 ERROR TypeError: Cannot read property 'OVERWRITE' of undefined
    at new e (main.03f1154228018f30c0ac.bundle.js:1)
    at e.applyServerOverwrite (main.03f1154228018f30c0ac.bundle.js:1)
    at e.updateInfo_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onConnectStatus_ (main.03f1154228018f30c0ac.bundle.js:1)
    at t.onRealtimeDisconnect_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.close (main.03f1154228018f30c0ac.bundle.js:1)
    at main.03f1154228018f30c0ac.bundle.js:1
    at e.invokeTask (polyfills.a77f1d02ca80765f17f1.bundle.js:1)
    at Object.onInvokeTask (main.03f1154228018f30c0ac.bundle.js:1)
    at e.invokeTask (polyfills.a77f1d02ca80765f17f1.bundle.js:1)
Oe @ main.03f1154228018f30c0ac.bundle.js:1
e.handleError @ main.03f1154228018f30c0ac.bundle.js:1
next @ main.03f1154228018f30c0ac.bundle.js:1
t.object.i @ main.03f1154228018f30c0ac.bundle.js:1
t.__tryOrUnsub @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t._next @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t.next @ main.03f1154228018f30c0ac.bundle.js:1
t.emit @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.runOutsideAngular @ main.03f1154228018f30c0ac.bundle.js:1
onHandleError @ main.03f1154228018f30c0ac.bundle.js:1
e.handleError @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
n.args.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
setTimeout (async)
c @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onScheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleMacroTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
d @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
i.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
F1yO.t.setTimeoutNonBlocking @ main.03f1154228018f30c0ac.bundle.js:1
e.start_ @ main.03f1154228018f30c0ac.bundle.js:1
e @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
i.g @ main.03f1154228018f30c0ac.bundle.js:1
Ze @ main.03f1154228018f30c0ac.bundle.js:1
Ye @ main.03f1154228018f30c0ac.bundle.js:1
TL6u.e.Qb @ main.03f1154228018f30c0ac.bundle.js:1
ke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvoke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvokeTask @ main.03f1154228018f30c0ac.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
v @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
n.args.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
setTimeout (async)
c @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onScheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleMacroTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
d @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
i.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleConnect_ @ main.03f1154228018f30c0ac.bundle.js:1
t.onOnline_ @ main.03f1154228018f30c0ac.bundle.js:1
e.on @ main.03f1154228018f30c0ac.bundle.js:1
t @ main.03f1154228018f30c0ac.bundle.js:1
e @ main.03f1154228018f30c0ac.bundle.js:1
e.createRepo @ main.03f1154228018f30c0ac.bundle.js:1
e.databaseFromApp @ main.03f1154228018f30c0ac.bundle.js:1
t.INTERNAL.registerService.Reference @ main.03f1154228018f30c0ac.bundle.js:1
e._getService @ main.03f1154228018f30c0ac.bundle.js:1
s.(anonymous function) @ main.03f1154228018f30c0ac.bundle.js:1
e @ main.03f1154228018f30c0ac.bundle.js:1
se @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
xi @ main.03f1154228018f30c0ac.bundle.js:1
Ii @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
xi @ main.03f1154228018f30c0ac.bundle.js:1
Ii @ main.03f1154228018f30c0ac.bundle.js:1
e.get @ main.03f1154228018f30c0ac.bundle.js:1
po @ main.03f1154228018f30c0ac.bundle.js:1
co @ main.03f1154228018f30c0ac.bundle.js:1
so @ main.03f1154228018f30c0ac.bundle.js:1
Uo @ main.03f1154228018f30c0ac.bundle.js:1
Lo @ main.03f1154228018f30c0ac.bundle.js:1
na @ main.03f1154228018f30c0ac.bundle.js:1
t.create @ main.03f1154228018f30c0ac.bundle.js:1
t.create @ main.03f1154228018f30c0ac.bundle.js:1
e.bootstrap @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e._moduleDoBootstrap @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvoke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvokeTask @ main.03f1154228018f30c0ac.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
v @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
Promise resolved (async)
d @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onScheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleMicroTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
P @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.then @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.appInitializer @ main.03f1154228018f30c0ac.bundle.js:1
e.runInitializers @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
onInvoke @ main.03f1154228018f30c0ac.bundle.js:1
e.invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.run @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.run @ main.03f1154228018f30c0ac.bundle.js:1
e.bootstrapModuleFactory @ main.03f1154228018f30c0ac.bundle.js:1
cDNt @ main.03f1154228018f30c0ac.bundle.js:1
o @ inline.e029292f71a17d803f23.bundle.js:1
0 @ main.03f1154228018f30c0ac.bundle.js:1
o @ inline.e029292f71a17d803f23.bundle.js:1
window.webpackJsonp @ inline.e029292f71a17d803f23.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
main.03f1154228018f30c0ac.bundle.js:1 FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'myID' of undefined
    at http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1186752
    at e.newRequest_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1186856)
    at e.startLongPoll (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1186493)
    at e.start (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1182574)
    at e.onHandshake_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1077185)
    at e.onControl_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1076527)
    at e.onPrimaryMessageReceived_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1076067)
    at e.onMessage_ (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1074274)
    at http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:1063122
    at Object.F1yO.t.exceptionGuard (http://localhost:4200/main.03f1154228018f30c0ac.bundle.js:1:120625) 
F1yO.t.warn @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
e.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.runTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.invokeTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
invoke @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
n.args.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
setTimeout (async)
c @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
e.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
t.scheduleMacroTask @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
d @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
(anonymous) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
i.(anonymous function) @ polyfills.a77f1d02ca80765f17f1.bundle.js:1
F1yO.t.exceptionGuard @ main.03f1154228018f30c0ac.bundle.js:1
t @ main.03f1154228018f30c0ac.bundle.js:1
i @ main.03f1154228018f30c0ac.bundle.js:1
e.handleResponse @ main.03f1154228018f30c0ac.bundle.js:1
(anonymous) @ main.03f1154228018f30c0ac.bundle.js:1
pRTLPCB @ .lp?start=t&ser=53021794&cb=1&v=5&ns=strongholdings-40ee8:6
(anonymous) @ .lp?start=t&ser=53021794&cb=1&v=5&ns=strongholdings-40ee8:9
polyfills.a77f1d02ca80765f17f1.bundle.js:1 Uncaught TypeError: Cannot read property 'myID' of undefined
    at main.03f1154228018f30c0ac.bundle.js:1
    at e.newRequest_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.startLongPoll (main.03f1154228018f30c0ac.bundle.js:1)
    at e.start (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onHandshake_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onControl_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onPrimaryMessageReceived_ (main.03f1154228018f30c0ac.bundle.js:1)
    at e.onMessage_ (main.03f1154228018f30c0ac.bundle.js:1)
    at main.03f1154228018f30c0ac.bundle.js:1
    at Object.F1yO.t.exceptionGuard (main.03f1154228018f30c0ac.bundle.js:1)

再次使用ng serve --aot项目呈现完美。我想部署所以我做了ng build --aot并且正确部署到firebase并且它可以工作。为什么我使用ng serve --prod收到此错误并继续部署--aot版本是否安全?当我执行ng build --prod

时,Angular CLI也不会抛出错误

任何帮助?

2 个答案:

答案 0 :(得分:0)

也许您使用的是旧版本的橡果(或者您的某个使用者正在使用它)? https://github.com/acornjs/acorn/issues/608

您可以尝试更新到^ 5.2.1

答案 1 :(得分:0)

在项目中的某些位置,您使用的是折旧方法items。将getToken替换为 getIdToken(true)

示例:

firebase.auth().currentUser.getToken