angular/universal

TypeError: (intermediate value).ngOnDestroy is not a function

yousaf101 opened this issue ยท 4 comments

๐Ÿž Bug report

What modules are related to this issue?

  • builders
  • common
  • express-engine

Is this a regression?

Based on the available information, it appears that this issue was recently reported and has not been encountered by many users. It seems to have emerged on the latest version of Angular, specifically version 15.0.3.

I conducted a thorough search on StackOverflow regarding a similar issue that was recently reported, but did not find any relevant solution suggestions. Therefore, I do not believe that this particular issue existed in any previous version.

You can check the following link as well for the issue: Angular 15: Getting TypeError: (intermediate value).ngOnDestroy is not a function at ServerStylesHost.ngOnDestroy

Description

After installing the "Angular Universal" library in my existing Angular-based website, I encountered an error in both the console and the browser when attempting to run the project. Consequently, I am currently unable to launch the app.

๐Ÿ”ฌ Minimal Reproduction

I used the following command to install Angular Universal in my project:

ng add @nguniversal/express-engine

Packages were installed successfully.

I run the project using the following command:

npm run dev:ssr

when i hit http://localhost:4200/ on URL, i get the following error in the console and on the browser as well

๐Ÿ”ฅ Exception or Error


TypeError: (intermediate value).ngOnDestroy is not a function
at ServerStylesHost.ngOnDestroy (C:\app\Website\app-website\dist\app-website\server\vendor.js:195650:11)
at R3Injector.destroy (C:\app\Website\app-website\dist\app-website\server\vendor.js:156089:17)
at NgModuleRef.destroy (C:\app\Website\app-website\dist\app-website\server\vendor.js:170556:37)
at C:\app\Website\app-website\dist\app-website\server\vendor.js:176822:52
at Array.forEach ()
at PlatformRef.destroy (C:\app\Website\app-website\dist\app-website\server\vendor.js:176822:27)
at complete (C:\app\Website\app-website\dist\app-website\server\vendor.js:195933:18)
at C:\app\Website\app-website\dist\app-website\server\vendor.js:195938:16
at _ZoneDelegate.invoke (C:\app\Website\app-website\dist\app-website\server\vendor.js:95968:158)
at Zone.run (C:\app\Website\app-website\dist\app-website\server\vendor.js:95709:35)

๐ŸŒ Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / โ–ณ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 15.0.3
Node: 14.20.0
Package Manager: npm 6.14.13
OS: win32 x64

Angular: 15.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.3
@angular-devkit/build-angular   15.0.3
@angular-devkit/core            15.0.3
@angular-devkit/schematics      15.0.3
@angular/cdk                    15.0.2
@angular/flex-layout            14.0.0-beta.41
@angular/platform-server        15.2.6
@nguniversal/builders           15.2.0
@nguniversal/express-engine     15.2.0
@schematics/angular             15.0.3
rxjs                            7.5.7
typescript                      4.8.4

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

Closing due to the lack of a reproduction.

I have the same error in my project. However, I created an empty project and added Universal package - everything works. It looks like some module or package from my project is interfering with Angular Universal. I'm going to transfer components and packages from my project one by one to determine which part of my project is causing this error. As soon as I find out, I'll post it here.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.