Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What is an Angular project definition?

You develop applications in the context of an Angular workspace. A workspace contains the files for one or more projects. A project is the set of files that comprise a standalone application or a shareable library. The Angular CLI ng new command creates a workspace.

How do you check Angular CLI is installed or not?

You can use npm list -global to list all the component versions currently installed on your system. For viewing specific lists at different levels use --depth . Show activity on this post. Go to your folder path in cmd where your angular is installed and type ng --version it will show your angular version.

How run ng serve in CMD?

To get the application running, the ng serve command must execute within the [name-of-app] folder. Anywhere within the folder will do. The Angular CLI must recognize that it is within an environment generated with ng new . It will run provided this one condition.


I was also getting this issue and solved by running below command.

ng update @angular/cli --migrate-only --from=<WhateverVersionYouAreCurrentlyOn>

e.g.

ng update @angular/cli --migrate-only --from=1.7.3

getting ref from here


make sure that you are running the command in the application root folder..


if you have downloaded a project,do in the project

npm install


Finally, the command below fixed the issue for me!

ng update --all --force

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

Problem was missing angular.json files.

    ng update --all --force

Tested in Angular 7+


It was silly me but need to leave comment maybe I save someone else some hassle. Same message happens if you multitask and have multiple projects so some of project is nested inside project folder like projectFolder/subProject/projectOne so I was in projectFolder/subProject trying to run command ng serve.

Make sure you are in correct folder because same error will occur if you are in wrong folder and conf and build is missing!


It was happening in my existing project as I tried to update to latest node and npm packages:

  1. Uninstall global: npm uninstall -g angular-cli
  2. Reset Cache: npm cache clean or npm cache verify (for npm version > 5)
  3. Install latest: npm install -g @angular/cli@latest