1

I am trying to upgrade an angular application (10 to 15) which basically is creating dynamic Angular components. Now, when I run ng serve I am getting the following error:

Error: NG0202
    at vn (VM910 main.js:1:19242)
    at Object.v8_Factory [as factory] (ɵfac.js:1:1)
    at P4.hydrate (VM910 main.js:1:59765)
    at P4.get (VM910 main.js:1:58804)
    at Io (VM910 main.js:1:19110)
    at In (VM910 main.js:1:19211)
    at E4.ɵfac [as factory] (VM910 main.js:1:2680700)
    at P4.hydrate (VM910 main.js:1:59765)
    at P4.get (VM910 main.js:1:58804)
    at Io (VM910 main.js:1:19110)

(anonymous) @   VM910 main.js:1
T.invoke    @   VM887 polyfills.js:23
T.run   @   VM887 polyfills.js:23
(anonymous) @   VM887 polyfills.js:23
T.invokeTask    @   VM887 polyfills.js:23
T.runTask   @   VM887 polyfills.js:23
ue  @   VM887 polyfills.js:23
Promise.then (async)        
Te  @   VM887 polyfills.js:23
je  @   VM887 polyfills.js:23
T.scheduleTask  @   VM887 polyfills.js:23
T.scheduleTask  @   VM887 polyfills.js:23
T.scheduleMicroTask @   VM887 polyfills.js:23
Fe  @   VM887 polyfills.js:23
b.then  @   VM887 polyfills.js:23
bootstrapModule @   VM910 main.js:1
6050    @   VM910 main.js:1
a   @   runtime.js:1
fe  @   VM910 main.js:23
(anonymous) @   VM910 main.js:23
n   @   runtime.js:1
(anonymous) @   runtime.js:1
(anonymous) @   runtime.js:1
(anonymous) @   runtime.js:1

I have been browsing through the internet for a few days now but in vain. Could anyone please guide could be the reason for this error? Even a generic idea would help.

Please let me know if more information is needed from my side

Shikhar Ambashta
  • 195
  • 3
  • 10
  • 1
    The [Angular documentation](https://update.angular.io/) usually advises against jumping major versions. Did you go through the proper steps for upgrading to each version? Then you can verify each version, so from 10 to 11, 11 to 12 etc and verify if everything is working before continuing to the next version. – Ryhazerus Apr 13 '23 at 07:14
  • 1
    as @Ryhazerus states - normally a major version changes brings breaking changes. go back to your code using v 10 and follow https://update.angular.io/?v=10.0-15.0 being careful to test every time you upgrade. that means clearing out node_modules after each upgrade, doing `npm i` and then `ng serve`and ensuring that ALL your testcases work before upgrading to the next version. – JoSSte Apr 13 '23 at 10:29
  • I followed the steps and the issue narrowed down to this function which creates a component class ``` function createComponent() { @Component({ selector: "selected-component", template: `
    ` }) class AngularComponent implements OnInit, AfterViewInit { ... } .... } ``` This goes on to create a module too in similar way. and then, compiling the same compiler.compileModuleAndAllComponentsSync If this class is commented, the error goes away Now, i need to find the Angular 15 way for the same
    – Shikhar Ambashta Apr 14 '23 at 11:49
  • Did you get any solution to this? – Anonymous Creator Jun 06 '23 at 19:37

0 Answers0