Angular Universal Starter:无法匹配任何路线。网址段:“ robots.txt”

时间:2018-11-28 13:18:06

标签: angular angular-cli robots.txt angular-universal

我下载了这个Angular通用入门版https://github.com/angular/universal-starter

从package.json安装所有依赖项,并尝试启动项目。 我首先运行“ ng build”命令,然后执行下一个命令“ npm run build:ssr && npm run serve:ssr”

一切正常,但有时我在终端收到下一条消息:

ERROR { Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'robots.txt'
Error: Cannot match any routes. URL Segment: 'robots.txt'
    at ApplyRedirects.noMatchError (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2557:20)
    at CatchSubscriber.selector (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2538:33)
    at CatchSubscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\catchError.js:48:31)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at TapSubscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\tap.js:75:26)
    at resolvePromise (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:814:31)
    at resolvePromise (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:771:17)
    at D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:873:17
    at ZoneDelegate.invokeTask (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:421:31)
    at Object.onInvokeTask (D:\universal-starter-master\universal-starter-master\node_modules\@angular\core\bundles\core.umd.js:16177:37)
    at ZoneDelegate.invokeTask (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:420:36)
    at Zone.runTask (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:188:47)
    at drainMicroTaskQueue (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:595:35)
    at ZoneTask.invokeTask (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:500:21)
    at ZoneTask.invoke (D:\universal-starter-master\universal-starter-master\node_modules\zone.js\dist\zone-node.js:485:48)
  rejection: Error: Cannot match any routes. URL Segment: 'robots.txt'
    at ApplyRedirects.noMatchError (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2557:20)
    at CatchSubscriber.selector (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2538:33)
    at CatchSubscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\catchError.js:48:31)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at TapSubscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\tap.js:75:26),
  promise:
   ZoneAwarePromise {
     __zone_symbol__state: 0,
     __zone_symbol__value: Error: Cannot match any routes. URL Segment: 'robots.txt'
    at ApplyRedirects.noMatchError (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2557:20)
    at CatchSubscriber.selector (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2538:33)
    at CatchSubscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\catchError.js:48:31)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at TapSubscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\tap.js:75:26) },
  zone:
   Zone {
     _properties: { isAngularZone: true },
     _parent:
      Zone {
        _properties: {},
        _parent: null,
        _name: '<root>',
        _zoneDelegate: [Object] },
     _name: 'angular',
     _zoneDelegate:
      ZoneDelegate {
        _taskCounts: [Object],
        zone: [Circular],
        _parentDelegate: [Object],
        _forkZS: null,
        _forkDlgt: null,
        _forkCurrZone: [Object],
        _interceptZS: null,
        _interceptDlgt: null,
        _interceptCurrZone: [Object],
        _invokeZS: [Object],
        _invokeDlgt: [Object],
        _invokeCurrZone: [Circular],
        _handleErrorZS: [Object],
        _handleErrorDlgt: [Object],
        _handleErrorCurrZone: [Circular],
        _scheduleTaskZS: [Object],
        _scheduleTaskDlgt: [Object],
        _scheduleTaskCurrZone: [Circular],
        _invokeTaskZS: [Object],
        _invokeTaskDlgt: [Object],
        _invokeTaskCurrZone: [Circular],
        _cancelTaskZS: [Object],
        _cancelTaskDlgt: [Object],
        _cancelTaskCurrZone: [Circular],
        _hasTaskZS: [Object],
        _hasTaskDlgt: [Object],
        _hasTaskDlgtOwner: [Circular],
        _hasTaskCurrZone: [Circular] } },
  task:
   ZoneTask {
     _zone:
      Zone {
        _properties: [Object],
        _parent: [Object],
        _name: 'angular',
        _zoneDelegate: [Object] },
     runCount: 0,
     _zoneDelegates: null,
     _state: 'notScheduled',
     type: 'microTask',
     source: 'Promise.then',
     data:
      ZoneAwarePromise {
        __zone_symbol__state: 0,
        __zone_symbol__value: Error: Cannot match any routes. URL Segment: 'robots.txt'
    at ApplyRedirects.noMatchError (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2557:20)
    at CatchSubscriber.selector (D:\universal-starter-master\universal-starter-master\node_modules\@angular\router\bundles\router.umd.js:2538:33)
    at CatchSubscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\catchError.js:48:31)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at MapSubscriber.Subscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:93:26)
    at MapSubscriber.Subscriber.error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\Subscriber.js:73:18)
    at TapSubscriber._error (D:\universal-starter-master\universal-starter-master\node_modules\rxjs\internal\operators\tap.js:75:26) },
     scheduleFn: undefined,
     cancelFn: null,
     callback: [Function],
     invoke: [Function] } }

我该如何解决? 要捕获此消息,我多次单击浏览器中的刷新按钮。

1 个答案:

答案 0 :(得分:0)

这是solution的作品。但是我仍然不明白,为什么开发人员这么简单就没有在项目中包含robots.txt。也许有一些原因?