October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Fix Angular NG2003: Missing Token

Angular NG2003 means a constructor parameter has no runtime injection token. Learn when to use a class token or InjectionToken and how to register its provider.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular error NG2003 means the compiler cannot find a runtime injection token for a constructor parameter. Check the parameter named in the diagnostic: if its type is an interface or another type erased from JavaScript, inject a shared InjectionToken; if it is a runtime class, make sure it has Angular injectable metadata. Then register the token or class with the appropriate provider.

What NG2003 means

Angular describes NG2003 as “There is no injection token for a constructor parameter at compile time.” It is a compiler error: Angular cannot determine the runtime key it needs to resolve that dependency. See Angular’s NG2003: Missing Token reference.

As an Amazon Associate I earn from qualifying purchases.

Some TypeScript types do not exist at runtime. Interfaces and generic-only types are erased when TypeScript is compiled, so Angular cannot use them directly as injection tokens. Primitive constructor parameter types, including string, number, boolean, and Object, are also common triggers.

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

Trace the parameter Angular cannot resolve

  1. Read the compiler diagnostic. Identify the constructor parameter Angular names.
  2. Inspect the class’s uses. Check where the class is instantiated or injected, and whether the parameter is intended to be a service, a configuration value, or another dependency.
  3. Check for a runtime token. A TypeScript interface or primitive type is not, by itself, a usable runtime key. For a class dependency, confirm that Angular can identify it as injectable. For an erased type or value, create an explicit token.
  4. Register the dependency. Add a provider for the class or token in the injector that needs to supply it.

Use an InjectionToken for interfaces and values

Define one exported InjectionToken for the value, then use that exact token instance both when registering the provider and when injecting the dependency. The description string helps identify the token in debugging, but it does not determine token identity. Two separately created tokens with the same description are still different keys. Angular documents this pattern in its InjectionToken API and dependency provider guide.

import { InjectionToken, Inject } from '@angular/core';

export interface AppConfig {
  apiUrl: string;
}

export const APP_CONFIG = new InjectionToken<AppConfig>('app.config');

// Register this same token instance in the relevant injector:
// { provide: APP_CONFIG, useValue: appConfig }

// Inject the same token in a class constructor:
// constructor(@Inject(APP_CONFIG) private config: AppConfig) {}

Keep the token in a shared module or file and import that exported constant wherever it is provided or injected. Register a value with a provider such as { provide: APP_CONFIG, useValue: appConfig }. If an appropriate default can be created centrally, an InjectionToken can also have a factory; consult the API reference for its factory options.

For class dependencies, check injectable metadata and providers

If the dependency is a class that exists at runtime, ensure Angular has the injectable metadata needed to use it. Angular’s NG2003 guidance points to @Injectable or @Inject as ways to make the dependency identifiable. Also ensure a provider is available in the injector where the dependency is requested. A recognized token without a provider can lead to a different error.

Distinguish NG2003 from NG0201

NG2003 and NG0201 describe different stages of dependency injection. NG2003 means Angular cannot identify a token for a constructor parameter at compile time. NG0201 (“No Provider Found”) means Angular has a token but cannot find a provider for it in the applicable injector. Fixing the missing token may therefore expose a provider-registration issue that needs its own remedy.

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

Version scope

Angular’s Error Encyclopedia currently identifies NG2003 as a compiler error; its page is labeled build Angular v22.2.1+sha-fa63bfa. The reference does not specify when the diagnostic was first introduced or document changes across versions, so consult the documentation corresponding to your installed Angular version if version history is relevant. The catalog is available at Angular Error Encyclopedia.

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 *

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan

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.