IlyaDeveloper
@IlyaDeveloper
Top Rated | Expert Web Developer

Как решить проблему при сборке проекта Angular?

Ребята у меня проблема, когда я вызываю ng name-project: prerender

Prerendering 12 route(s) to /Users/twic/var/www/newhope/dist/newhope-surrogacy...ERROR NetworkError
  at XMLHttpRequest3.send (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2437770)
  at Observable._subscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:123191)
  at Observable._trySubscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2268050)
  at Observable.subscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2267832)
  at SwitchMapOperator.call (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2315482)
  at Observable.subscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2267686)
  at CatchOperator.call (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2301714)
  at Observable.subscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2267686)
  at DoOperator.call (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2319735)
  at Observable.subscribe (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:2267686)
ERROR TypeError: Cannot set properties of null (setting 'statusCode')
  at HopeNotComponent.ngOnInit (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/185.js:1:12034)
  at callHook (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:174673)
  at callHooks (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:174290)
  at executeInitAndCheckHooks (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:173626)
  at refreshView (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:280356)
  at refreshEmbeddedViews (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:300665)
  at refreshView (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:280484)
  at refreshComponent (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:301386)
  at refreshChildComponents (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:277202)
  at refreshView (/Users/twic/var/www/newhope/dist/newhope-surrogacy/server/main.js:1:280981)
✔ Prerendering routes to /Users/twic/var/www/newhope/dist/newhope-surrogacy complete.


проблема возникает? что мне делать с раствором?

export class HopeNotComponent implements OnInit {

  constructor(
    @Inject(PLATFORM_ID) private platformId: object,
    @Optional() @Inject(RESPONSE) private response: any,
    protected metaService: Meta,
    protected titleService: Title,) {
  }

  ngOnInit(): void {
    this.titleService.setTitle(ceo404Page.TITLE);
    this.metaService.updateTag({name: 'description', content: ceo404Page.DESCRIPTION});
    this.metaService.updateTag({name: 'keywords', content: ceo404Page.KEYWORDS});

    if (isPlatformServer(this.platformId)) {
      // this.response.status(404);
      this.response.statusCode = 404;
      this.response.statusMessage = '404 - Page Not Found';
    }
  }
}


Это экраны [1] [2]
  • Вопрос задан
  • 93 просмотра
Пригласить эксперта
Ответы на вопрос 1
@kttotto
пофиг на чем писать
В сообщении все написано
ERROR TypeError: Cannot set properties of null (setting 'statusCode')

Не может проинициализировать поле, т.к. оно null

this.response наверняка undefined или null во время открытия компонента.
Добавь проверку
if (!!this.response) {
  this.response.statusCode = 404;
  this.response.statusMessage = '404 - Page Not Found';
}
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы