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

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

Root Cause - When there is no project definition file in your project then you will see this error when you will run ng-serve or ng-build commands.

Project definition file - In Angular project definition file is generated when you create new application or upgrade existing application. In Angular versions lesser than 6 this file name is .angulat-cli.json and in Angular version 6 and above it's name is angular.json .

Solution -  So while running the angular build or run commands make sure you have correct project definition file. If you are upgrading your application from Angular 5 or lesser versions to Angular 6 and greater versions then you need to run below command to generate new project definition and other related files.

ng update @angular/cli   // run it twice,

If it's not generating then again try to run below commands in same sequence.

npm install -g @angular-devkit/core

npm install -g @angular/cli

npm install @angular/cli

ng update @angular/cli


Thanks

Comments

Popular posts from this blog

Swagger for Azure functions: Undocumented TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. Fixed.

System.Net.Http.HttpClient' does not contain a definition for 'PostAsJsonAsync

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance