I have an Ionic4/Angular 7/8 app. I want to create a component and have it auto configured in a specific module using the Angular CLI 7.3.9 and 8.1.3, but keep getting the error "File ... does not exist."
None of the answers in this post works either. Create component to specific module with Angular-CLI
Steps to reproduce the issue:
- Create module:
ng g module pets
This created a file named pets.module.ts in the [my_project_dir]/src/app/pets directory.
- Generate a component and add to specified module using CLI 7.3.9 or 8.1.3
ng g component pets/cat --module=pets.module.ts
ng g component pets/cat --module=pets/pets.module.ts
Executing the either the above command from my project directory or from the [my_project_dir]/src/app directory triggered this error message File pets/pets.module.ts does not exist.
Issuing this command ng g component pets/cat -m pets.module.ts
in 7.3.9 created the component cat, but neither pets.module.ts or app.module.ts was updated.
Issuing the command ng g component pets/cat -m pets.module.ts
in 8.1.3 caused this error message: Unknown option: '-m'
As a workaround, I could update the module.ts file manually but would like to know the solution for future reference. Any help is appreciated. Thanks.
Updated 10/16/2019 6:30pm
It works if the Angular app is created using ng new app-name
command, but does NOT if the app is generated via the ionic start app-name blank --type=angular
command although the project structure is very similar between the two apps.