Angular 6 CLI Component & Service Generate Issue

Angular 6 CLI Component & Service Generate Issue
Rating: 5 - 1 Votes

Angular 6 CLI Component & Service Generate Issue

Most of the developers these days are using Angular as their front-end to build Single Page Application, so do I.  This is not new that every Angular update comes with some minor changes and updating your existing project to the latest definitely affect your project.  Today, I tried to upgrade my Angular 4 project to Angular 6 and so far it all looked good, no issues!

But strange thing happened, when I tried to generate a new component using the following command

ERROR:

Specified module does not exist

 

Tried 2nd command

ERROR:

Could not find an NgModule. Use the skip-import option to skip importing in NgModule.

Tried 3rd command

Now, there was no error but the component was generated in e2e folder instead of my app folder.

How did I fix it?

In the angular.json file, I searched for:

my-project-e2e

Replace my-project with your project name.

Changed:

      “root”: “” to  “root”: “e2e”

Just saved it and everything was fine again!