main.ts:7 RuntimeError: NG0203: The `EnvironmentInjector` token injection failed

Discussão em 'Angular' iniciado por Apoorva Singh, Abril 9, 2025.

  1. I created a new Angular standalone application using ng new frontend --standalone with Node version 20.15.1 and Angular version 19.0.7. I'm getting the below error on ng serve. I didn't add any code, it's a basic application.

    main.ts:7 RuntimeError: NG0203: The `EnvironmentInjector` token injection failed. `inject()` function must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.dev/errors/NG0203
    at injectInjectorOnly (core.mjs:1097:11)
    at ɵɵinject (core.mjs:1114:40)
    at Object.factory (core.mjs:19081:42)
    at core.mjs:2238:35
    at runInInjectorProfilerContext (core.mjs:878:5)
    at R3Injector.hydrate (core.mjs:2237:11)
    at R3Injector.get (core.mjs:2116:23)
    at __spreadProps.getStandaloneInjector (core.mjs:19121:31)
    at createRootViewInjector (core.mjs:17317:44)
    at ComponentFactory2.create (core.mjs:17387:32)

    Continue reading...

Compartilhe esta Página