angular.json file not found error when building an

2019-07-13 12:15发布

问题:

I clone a repository on my laptop which I had created this source one month ago from another computer. My project was successful and that didn't have any kind of error one month ago. but today after I cloned the repository in new computer i faced with some errors. Actually I wrote npm i for installing packages then i tried to build my project via ng build

but these error happend:

Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found.

someone suggest me to delete npm and npm-cache from AppData\Roaming and delete package-lock.json from the src directory, then install package again. but this solution doesn't work.

回答1:

I Supposed your project is use an old version of angular cli (this use the angular-cli.json file) and on your computer is a newer version that require the angular.json instead.

In order to archieve this you should run ng update @angular/cli. Somethimes it require to run this twice. Then you should have an updated project.

The official documentation for updates allow the flag migrate-only. This can be usefull if you only want to archieve a migration and not a complete update. then run: ng update @angular/cli --from=x.x.x --migrate-only where x.x.x represents your actual version of cli.



标签: angular npm