Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk2 min

Replace Angular’s Deprecated ENVIRONMENT_INITIALIZER Safely

Angular deprecated ENVIRONMENT_INITIALIZER in v19. Replace it with provideEnvironmentInitializer for environment injector setup, or choose an app or platform initializer for a different lifecycle.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ENVIRONMENT_INITIALIZER is deprecated in Angular 19.0. For a synchronous callback that should run when an environment injector is constructed, use provideEnvironmentInitializer. For application-startup work that must wait for a Promise or Observable, use provideAppInitializer instead.

What ENVIRONMENT_INITIALIZER does

ENVIRONMENT_INITIALIZER is an @angular/core injection token for callbacks executed when an environment injector is constructed. Its type is InjectionToken<readonly (() => void)[]>. Angular marks the token deprecated since v19.0 and recommends provideEnvironmentInitializer for this lifecycle scope. Angular API reference

As an Amazon Associate I earn from qualifying purchases.

This is injector-construction work, not a general-purpose synonym for every task performed during application bootstrap. Choose an initializer according to the lifecycle that owns the work.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to migrate to provideEnvironmentInitializer

Replace the legacy token provider with Angular’s helper in the provider list for the environment injector. The helper’s callback runs in an injection context, so it can use dependency injection there. Angular API reference

import { createEnvironmentInjector, provideEnvironmentInitializer } from '@angular/core';

const injector = createEnvironmentInjector([
  provideEnvironmentInitializer(() => {
    // Synchronous work for this environment injector
  }),
], parentInjector);

Angular documents provideEnvironmentInitializer as returning EnvironmentProviders, with a callback signature of () => void. Its documented example supplies the helper in the provider array passed to createEnvironmentInjector. Angular API reference

If you still use the legacy token

The token is a multi-provider token. If you retain its old provider form, include multi: true; omitting it can cause Angular’s NG0209 invalid multi-provider error. New code should use the replacement helper. Angular NG0209 documentation

{
  provide: ENVIRONMENT_INITIALIZER,
  multi: true,
  useValue: () => {
    // Environment-injector initialization work
  },
}

Choose the initializer that matches the lifecycle

When the work should run API What it does
When an environment injector is constructed provideEnvironmentInitializer Runs a synchronous callback in an injection context.
During application startup, with asynchronous work to finish first provideAppInitializer If the callback returns a Promise or Observable, application initialization waits for the Promise to resolve or the Observable to complete. Angular API reference
When the platform injector is initialized providePlatformInitializer Provides a callback at platform level during platform creation. Angular API reference

These APIs have similar names but different lifecycle scopes. In particular, the documented environment initializer accepts a synchronous () => void callback; use the application initializer when startup must await a Promise or Observable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What Angular’s deprecation means

The API reference records deprecation beginning in Angular v19.0, but does not name a removal release for ENVIRONMENT_INITIALIZER. Angular’s general policy says deprecated APIs remain available through at least the next major release and may be removed only in a later major release. That policy does not establish a token-specific removal date. Angular release policy

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.