When generating a new component using ng g c my-component
I get the error:
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
If I then use the skip-import option Angular generates the component in my e2e folder.
I'm assuming it's something to do with my angular.json
file which used to be called angular-cli.json
prior to me running ng upgrade which is no doubt what caused the issue as there seems to have been some structural changes.
Is there way to fix this without creating a new project with the CLI and then manually copying over files..?
ng g c ran from root "my-app" folder.
Folder structure:
my-app
- dist
- e2e
- node_modules
- src
- app
- etc
angular.json within my-app folder
**Angular Versions:**
@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cli 6.0.8
@ngtools/webpack 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 5.5.2
typescript 2.5.3
webpack 4.8.3
I smell ng finds multiple module files on app root, please supply module while generating component
ng generate component componentName --module=<MODULE-NAME>
ng generate component componentName --module=app.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