Shikhar Ambashta
Shikhar Ambashta

Reputation: 353

Getting error on `ng serve` : Error: NG0202

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

Upvotes: 0

Views: 1031

Answers (1)

Pedro Alves
Pedro Alves

Reputation: 31

For anyone who suffered from this in the future: in my case, the problem was override a native provider from the @angular/platform-browser package using the build configuration below. The temporary solution was to remove the provider override.

Angular version: 15 Node version: 18

{
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.prod.ts"
    }
  ],
  "optimization": true,
  "outputHashing": "all",
  "sourceMap": false,
  "namedChunks": false,
  "aot": false,
  "extractLicenses": true,
  "vendorChunk": false,
  "buildOptimizer": false,
  "extraWebpackConfig": "webpack.prod.config.js"
}

Upvotes: 0

Related Questions