Angular 19 `toObservable` causing `ng build` error TypeError: r.notifier.notify is not a...

Discussão em 'Angular' iniciado por Alex Pappas, Março 3, 2025.

  1. Alex Pappas

    Alex Pappas Guest

    The following code:

    import { toObservable } from '@angular/core/rxjs-interop';
    ...
    export class MyService {
    readonly myData= signal<MyData| null>(null);
    // toObservable creates a cold observable. Use startWith to make it function as a BehaviorSubject.
    readonly myData$ = toObservable(this.myData).pipe(startWith(this.myData()));


    Causes an error on ng build:

    X [ERROR] An error occurred while extracting routes
    TypeError: r.notifier.notify is not a function
    at ** (file:///C:/Users/**/.angular/prerender-root/**/chunk-**.mjs:34:86300)
    ....


    I am not entirely sure how to move forward from this other than ditch the function toObservable for now. It seems that it fails at prerendering or some other phase of the ng build. The r.notifier.notify is already internal to Angular and is beyond the scope of the application layer.

    Continue reading...

Compartilhe esta Página