I have the following directory structure
I would like to create a new page, let's say, an About page. I want to put it in src/app/page/about/*
So I try:
ng generate component pages/about
but I get this error:
Error: More than one module matches. Use skip-import option to skip importing the component into the closest module. More than one module matches. Use skip-import option to skip importing the component into the closest module.
Is it a good idea to use pages to store my separate pages? How can I generate components in a subdirectory using the angular-cli?
We can use ng generate component command to create component in sub-directory or specific folder.
Because there are 2 modules (app.module.ts
, shared.module.ts
) found the CLI does not know which module to declare your component in. To get around this you have to tell the CLI which module you wish to declare your component in with the module
option
ng generate component pages/about --module=app.module // or ng generate component pages/about --module=shared.module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With