通过ng build构建角度项目时找不到angular.json文件错误 [英] angular.json file not found error when building angular project via ng build
问题描述
我在笔记本电脑上克隆了一个存储库,该存储库是我一个月前从另一台计算机创建的源.我的项目成功了,一个月前没有任何错误.但是今天,在将存储库克隆到新计算机中之后,我遇到了一些错误.实际上,我写了 npm i
来安装软件包,然后尝试通过 ng build
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
但是发生了这些错误:
找不到本地工作区文件('angular.json').错误:本地找不到工作区文件('angular.json').
Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found.
有人建议我从 AppData \ Roaming
中删除 npm
和 npm-cache
并删除 package-lock.json
src
目录中的code>,然后再次安装软件包.但是此解决方案不起作用.
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.
推荐答案
我假设您的项目使用的是旧版本的angular cli(使用 angular-cli.json
文件),并且在您的项目上计算机是较新的版本,而需要 angular.json
.
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.
要对此进行归档,您应该运行 ng update @ angular/cli .Somethimes需要运行两次.然后,您应该有一个更新的项目.
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.
用于更新的官方文档允许标记 migrate-仅
.如果您只想归档迁移而不是完整的更新,这可能很有用.然后运行: ng update @ angular/cli --from = x.x.x-仅迁移
其中 x.x.x
代表您的cli的实际版本.
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.
这篇关于通过ng build构建角度项目时找不到angular.json文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!