1

I have the following structure:

-AppModule
  --AdminModule
    ---HomepageModule

How I can create a component HomepageModule Component?

I tried:

ng g c admin/homepage/my-new-component
ng g c admin/homepage/my-new-component --module homepage

I get the following error:

Error: More than one module matches. Use skip-import option to skip importing the component into the closes
t module.
More than one module matches. Use skip-import option to skip importing the component into the closest modul
e.

Any idea?

TheUnreal
  • 23,434
  • 46
  • 157
  • 277
  • 3
    Possible duplicate of [How to generate components in specific folder with angular-cli?](https://stackoverflow.com/questions/46851399/how-to-generate-components-in-specific-folder-with-angular-cli) – Sajeetharan Oct 25 '17 at 08:26
  • Did you look at what I tried? because it's same – TheUnreal Oct 25 '17 at 09:11
  • you can go to the folder of the module ,then run you command `ng g c my-new-component` , it will be created in the module – Mohamed Ali RACHID Oct 25 '17 at 09:14

1 Answers1

1

As the warning says, It's because you have more than one module

You can solve it by specifying the name of the module you want to import the component to it.

for example

    ng generate component componentName --module=app.module

Source

Felix Runye
  • 2,135
  • 1
  • 20
  • 20