Sandra Willford
Sandra Willford

Reputation: 3789

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

in previous versions i have just been able to generate a new component like this...

ng g c modules/update-tables/containers/users-container

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

then i tried...

ng g c containers/users-container --module=update-tables

Error: Specified module does not exist

then i tried...

ng g c containers/users-container --module UpdateTablesModule

Error: Specified module does not exist

enter image description here

Upvotes: 0

Views: 24567

Answers (3)

woyvch
woyvch

Reputation: 47

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

Upvotes: 0

mohsenmadi
mohsenmadi

Reputation: 2377

I have ran through this issue before. There is nothing stopping you from creating the module yourself. Llook at any existing one to see the pattern such as including @NgModule and all. For the file, create a file named users-container.module.ts. Then add it to the imports section in the app.module.ts (or wherever module you need to include it in) yourself.

Upvotes: 0

Martin Adámek
Martin Adámek

Reputation: 18389

You should specify relative path to your *.module.ts file from /app folder:

ng g c containers/users-container ./modules/update-tables/update-tables/update-tables.module.ts

You can also omit the .module.ts suffix:

ng g c containers/users-container ./modules/update-tables/update-tables/update-tables

It even works without the module name, then it will take the first one in given folder, so it might be better to specify it:

ng g c containers/users-container ./modules/update-tables/update-tables

Upvotes: 1

Related Questions