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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Angular error NG2003 means the compiler cannot identify a runtime injection token for a constructor parameter. Check the parameter named in the error: if its type is an interface or a primitive such as string, Angular needs an explicit InjectionToken; if it is a class dependency, ensure it has Angular injectable metadata. Then register the corresponding provider. These are separate steps: fixing NG2003 identifies the token, while a missing provider can lead to NG0201.

What NG2003 means

Angular classifies NG2003: Missing Token as a compiler error. Its message means Angular cannot determine a usable injection token for a constructor parameter at compile time. Dependency injection needs a runtime key; a TypeScript type that disappears during compilation cannot supply one.

Angular lists string, number, boolean, and Object as common examples of parameter types that can trigger this error. Interfaces are another frequent case because TypeScript erases them from the emitted JavaScript.

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

How to diagnose the parameter

  1. Start with the reported constructor parameter. Read the compiler location and inspect the parameter and the class that declares it.
  2. Check whether the type exists at runtime. A class can act as a token when Angular has the required injectable metadata. An interface, generic-only type, or primitive type does not by itself provide a suitable runtime token.
  3. Choose the matching fix. Use an injectable class for a class dependency, or define an InjectionToken for a value whose TypeScript type is erased or is not itself a class.
  4. Register a provider for that token. Make sure it is available in the injector that needs to resolve the dependency.

Fix an interface or other erased type with InjectionToken

Use InjectionToken when the dependency is an interface-typed value or another value without a runtime class token. Export one token constant and use that exact instance both when registering the provider and when injecting the value. The description string helps identify the token in debugging, but it does not determine token identity.

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

export interface AppConfig {
  apiUrl: string;
}

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

Register the same token in the relevant injector, for example with a value provider:

{ provide: APP_CONFIG, useValue: appConfig }

Inject that same token where it is needed. With constructor injection, use @Inject(APP_CONFIG) to associate the parameter with the runtime token. Angular documents provider patterns in Defining dependency providers.

Fix a class dependency

If the constructor parameter is meant to receive a class-based service, ensure Angular can recognize that class as injectable. Angular’s NG2003 guidance recommends @Injectable or @Inject as appropriate to reify the dependency type. Also provide the service in an injector that covers the requesting class; otherwise, token resolution may advance past NG2003 but fail because no provider is available.

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

Distinguish NG2003 from NG0201

NG2003 is about identifying the token at compile time. NG0201, “No Provider Found,” is a different problem: Angular has a token but cannot find a provider for it in the relevant injector hierarchy. After supplying a token, treat NG0201 as a provider-registration issue and check where that provider is configured.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version scope

Angular’s current Error Encyclopedia identifies NG2003 as a compiler error. Its page is labeled for Angular v22.2.1+sha-fa63bfa, but it does not state when the diagnostic was first introduced or describe changes across Angular versions. If version history or behavior in an older installation matters, check the documentation for the Angular version in use. The encyclopedia is available at angular.dev/errors.

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.