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?

3
  • 3
    Possible duplicate of How to generate components in specific folder with angular-cli? Commented Oct 25, 2017 at 8:26
  • Did you look at what I tried? because it's same Commented Oct 25, 2017 at 9: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 Commented Oct 25, 2017 at 9:14

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.