当我使用命令ng serve --prod
运行我的Angular 5应用程序时,构建阶段成功,我没有任何编译错误。
一旦启动应用程序,我就会收到此错误:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'startsWith' of null
TypeError: Cannot read property 'startsWith' of null
at t.peekStartsWith (router.js.pre-build-optimizer.js:1553)
at t.consumeOptional (router.js.pre-build-optimizer.js:1563)
at t.parseRootSegment (router.js.pre-build-optimizer.js:1357)
at t.parse (router.js.pre-build-optimizer.js:1204)
at t.applyRedirectCommands (router.js.pre-build-optimizer.js:2062)
at t.expandRegularSegmentAgainstRouteUsingRedirect (router.js.pre-build-optimizer.js:1937)
at t.expandSegmentAgainstRouteUsingRedirect (router.js.pre-build-optimizer.js:1887)
at t.expandSegmentAgainstRoute (router.js.pre-build-optimizer.js:1861)
at e.project (router.js.pre-build-optimizer.js:1798)
at e._next (map.js.pre-build-optimizer.js:79)
at t.peekStartsWith (router.js.pre-build-optimizer.js:1553)
at t.consumeOptional (router.js.pre-build-optimizer.js:1563)
at t.parseRootSegment (router.js.pre-build-optimizer.js:1357)
at t.parse (router.js.pre-build-optimizer.js:1204)
at t.applyRedirectCommands (router.js.pre-build-optimizer.js:2062)
at t.expandRegularSegmentAgainstRouteUsingRedirect (router.js.pre-build-optimizer.js:1937)
at t.expandSegmentAgainstRouteUsingRedirect (router.js.pre-build-optimizer.js:1887)
at t.expandSegmentAgainstRoute (router.js.pre-build-optimizer.js:1861)
at e.project (router.js.pre-build-optimizer.js:1798)
at e._next (map.js.pre-build-optimizer.js:79)
at D (zone.js:824)
at D (zone.js:795)
at zone.js:873
at e.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js.pre-build-optimizer.js:4724)
at e.invokeTask (zone.js:424)
at t.runTask (zone.js:192)
at d (zone.js:602)
有人知道是什么原因引起的吗?不在生产模式下构建的相同应用程序(即ng serve
)可以完美地运行