Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular

I'm getting the following error after an npm audit fix --force (I know, I know).

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

I'm guessing that I need a project.json file however I can't find a template (or documentation) for that.

Extracts from my package.json:

  "dependencies": {
    "@angular/animations": "^5.0.3",
    "@angular/common": "^5.0.3",
    "@angular/compiler": "^5.0.3",
    "@angular/core": "^5.0.3",
    "@angular/forms": "^5.0.3",
    "@angular/http": "^5.0.3",
    "@angular/platform-browser": "^5.0.3",
    "@angular/platform-browser-dynamic": "^5.0.3",
    "@angular/router": "^5.0.3",

  "devDependencies": {
    "@angular/cli": "^7.2.3",  <-- previously 1.5.4
    "@angular/compiler-cli": "^5.0.3",

(can post full file if needed)

image desc

like image 356
Allan Bowe Avatar asked Dec 23 '22 01:12

Allan Bowe


2 Answers

Credit to @dmoore1181 and @Edric for pointing out that the missing file was indeed angular.json and that an upgrade was needed.

Following the advice in this question, I completed the upgrade but still didn't have an angular.json - what did this for me in the end (and also mentioned in the answer to that question) was the following command:

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

like image 62
Allan Bowe Avatar answered May 06 '23 14:05

Allan Bowe


Create a new project with ng new and that should create the file you need. Then you can copy it over to your project.

like image 44
dmoore1181 Avatar answered May 06 '23 15:05

dmoore1181