More than one module matches

When an Angular application has more than one module, then we tend to get into an issue while generating a new component.

This can even happen while generating other Angular components, not just a component.

ng g c component-name

The error message states that the component generation skipped it finds more than one module matches as shown below.

More than one module matches. Use the skip-import option to skip importing the component into the closest module or use the module option to specify a module.

How to fix this issue?

We can fix the above issue by generating a component by specifying the module name as shown below.

  • The component name is component-name
  • The module name is app
  • Module app is the default application module
ng g c component-name --module app

Overall

We now know how to resolve the multiple module matches issue.