Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The generate command requires to be run in an Angular project, but a project definition could not be found

Tags:

angular

at the time I'm going to create component using ng g component command I facing with this error what I need to do to solve this.

"The generate command requires to be run in an Angular project, but a project definition could not be found."

like image 895
Avinash Avatar asked Dec 08 '18 07:12

Avinash


4 Answers

You can also get this behavior if you are confusing ng new with ng g application .

like image 155
Kate at LittleCollie Avatar answered Sep 20 '22 15:09

Kate at LittleCollie


After ng new project make sure you entered project directory in terminal.

like image 20
Sourav Das Avatar answered Sep 19 '22 15:09

Sourav Das


Your project folder must either contain angular.json or angular-cli.json.

The above mentioned file contains your project definition and its structure. So, that's why without these files and without angular-cli installed. You won't be able to run, ng g component command successfully.

like image 29
Saddam Pojee Avatar answered Sep 16 '22 15:09

Saddam Pojee


  1. Check you are in correct project or not.
  2. Check angular.json file in your project first,if it is missing,add file.
  3. Update angular CLI.
like image 29
Chirag Avatar answered Sep 18 '22 15:09

Chirag