'The build command requires to be run in an Angular project, but a project definition could not be found
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)
Solution 1:[1]
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
Solution 2:[2]
Create a new project with ng new
and that should create the file you need. Then you can copy it over to your project.
Solution 3:[3]
If you have the Nx Console installed, use that to build your project. Or from the command line it is:
npx ng run {app-name}:build
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Allan Bowe |
Solution 2 | dmoore1181 |
Solution 3 | Emi OB |