0

I have been assigned a task where I have to run ng serve command in folder.

I have following folder structure:

ProjectFolder - > ClientApp - >Src
                            -> dist
                            -> e2e

I am running this command inside ProjectFolder and I am getting this error:

The serve Command requires to be angular project but project definition could not found.

Is my path is wrong? In which folder shall I run this command ? ClientApp or Src?

If I make new project and serve this ng serve,it is working.

Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
Pinky
  • 47
  • 2
  • 5
  • you need to run ng serve command in ClientApp project. you can learn angular cli common on angular io https://angular.io/cli – Bansi29 Oct 21 '21 at 06:47
  • can you attach an image of your project structure with opened directories of your project? – Mahdi Zarei Oct 21 '21 at 06:48
  • Does this answer your question? [The serve command requires to be run in an Angular project, but a project definition could not be found](https://stackoverflow.com/questions/53182110/the-serve-command-requires-to-be-run-in-an-angular-project-but-a-project-defini) – Mahdi Zarei Oct 21 '21 at 06:53

1 Answers1

1

You have to run the ng serve command on the root level of the project, In your case its ClientApp. I think you don't have node modules in your project structure, In case you don't have it, then run the 'npm install' command in the ClientApp folder, this will install the node modules. after successfully installing the node modules, you can try 'ng serve' command

Goutham Harshith
  • 238
  • 2
  • 16
  • Thanks Harshith for ur answer.Yes,I don't have node modules in my project.Do it necessary to have node module folder in project? what is role of it?I have installed node.js and checked it's version. Run this command npm install -g @angular/core @angular/cli. – Pinky Oct 21 '21 at 07:07
  • When I am running ng serve inside clientApp,getting msg :An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' Require stack: .So many error like AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js – Pinky Oct 21 '21 at 10:59
  • Yes, For any front-end project you need to have node modules in project setup, node modules are nothing but the required dependencies for your project. Did the issue resolved? – Goutham Harshith Oct 22 '21 at 05:29
  • Will npm i ,install all dependancy involved package.json.Will it not include devdependancy? – Pinky Oct 22 '21 at 10:31