What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

NG6100 is a warning about id: module.id inside Angular @NgModule metadata. Angular ignores that declaration and warns because the ID is rarely useful and makes the NgModule non-tree-shakable. In most applications, remove only the id property; keep the rest of the module unchanged.

What NG6100 means

Angular documents @NgModule({ id: module.id }) as a common anti-pattern. The compiler ignores the declaration and emits NG6100. The id field is intended for a specific purpose: registering a module so code can retrieve it with getNgModuleById(). That lookup is uncommon and mainly applies when a lazily loaded NgModule must be found without a direct reference.

Angular also warns that supplying an NgModule ID makes the module non-tree-shakable, which can affect bundle size. The documentation does not quantify the effect, so there is no reliable fixed size reduction to expect from removing the property.

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

How to fix the warning

Remove the id metadata entry if the application does not deliberately use getNgModuleById().

@NgModule({
  id: module.id,
  // other metadata
})
export class FeatureModule {}

Change it to:

@NgModule({
  // other metadata
})
export class FeatureModule {}

This focused change resolves the anti-pattern without requiring a project-wide migration away from NgModules.

Check for a real ID lookup before removing it

  1. Search the project for getNgModuleById().
  2. If there are no deliberate calls that depend on the module being registered by ID, remove the id property.
  3. If the application does use that lookup, confirm why it needs to find the module without a direct reference and whether the bundling arrangement depends on it. Use a meaningful, stable string ID only for that intentional case, and account for Angular’s tree-shaking caveat.

Angular’s NgModule API describes the id field and lookup behavior: NgModule API reference.

Use dynamic import for ordinary lazy loading

For most code that needs to load a module lazily, Angular recommends an ES dynamic import(). It gives the caller a direct reference to the imported module rather than relying on global registration and later lookup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const module = await import('./path/to/module');

Choose this approach when the goal is simply to load code on demand. Reserve an NgModule ID and getNgModuleById() for a specific situation that genuinely requires lookup without a direct reference. Angular’s NG6100 guidance explains the warning and recommends dynamic imports for most cases.

Why the pattern appears in older code

The NgModule id is sometimes confused with historical component metadata. Earlier Angular versions sometimes used moduleId: module.id in @Component metadata; that is a different field with a different purpose. Angular’s framework issue notes that Ivy no longer respects @Component.moduleId for resource resolution, unlike older View Engine behavior. The issue was opened on December 14, 2022: Angular issue #48490.

That history does not make @NgModule({ id: module.id }) necessary. Angular’s current NG6100 documentation says CommonJS module.id is usually opaque to consumers and therefore typically does not provide a useful lookup ID.

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

Do you need to migrate from NgModules?

No. Removing an unused id is a targeted warning fix, not a requirement to convert the application to standalone components. Angular recommends standalone components for new code, while its NgModules guide remains useful for understanding existing module-based applications: Angular NgModules guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy 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.