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

后端 未结 3 1898
面向向阳花
面向向阳花 2020-12-22 14:52

When I try to create a component in the angular cli, it\'s showing me this error. How do I get rid of it ?

Error: More than one module matches. Use sk

相关标签:
3条回答
  • 2020-12-22 15:29

    Try This: It is working for me

    ng generate component componentName --module=app.module

    0 讨论(0)
  • 2020-12-22 15:43

    Specify the module using the --module parameter. For example, if the main module is app.module.ts, run this:

    ng g c new-component --module app
    

    Or if you are in an other directory then

    ng g c component-name --module ../
    
    0 讨论(0)
  • 2020-12-22 15:47

    This is caused since the generation tried to add your component to a module, i.e. to add this line

    import { MyComponent } from './Components/my-component/my-component.component';
    

    but it found 2 modules.

    As stated here, they fixed it to a situation where as long as in the root src/app folder you have only 1 module, you're fine, so just move the secondaries modules to a sub-folder.

    Otherwise you have to use --module

    0 讨论(0)
提交回复
热议问题