Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular

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 skip-import option to skip importing the component into the closest module.

I'm using angular cli version: 1.4.1

like image 541
Ish Man Avatar asked Sep 12 '17 11:09

Ish Man


People also ask

What is the use of skip import option?

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

Can we have more than one module in Angular?

So now, you need to follow some simple steps to use multiple modules in an Angular application. Create a simple application using Angular CLI. If you are going to use Angular for the first time, click here. I am going to create an application which contains three modules: App, Employee, Admin, Home.

What is module and component in Angular?

Typically module is a cohesive group of code which is integrated with the other modules to run your Angular apps. A module exports some classes, function and values from its code. The Component is a fundamental block of Angular and multiple components will make up your application.


2 Answers

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 ../ 
like image 167
zisha Avatar answered Sep 30 '22 14:09

zisha


Try This: It is working for me

ng generate component componentName --module=app.module

like image 30
Shurvir Mori Avatar answered Sep 30 '22 15:09

Shurvir Mori