在Angular 6更新之后,ng build –prod产生“错误:期望找到一个ngsw-config.json配置文件”

前端之家收集整理的这篇文章主要介绍了在Angular 6更新之后,ng build –prod产生“错误:期望找到一个ngsw-config.json配置文件”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
更新很顺利,但现在当我构建时,我收到以下错误.

Error: Expected to find an ngsw-config.json configuration file in the
/Users/nathanielmay/Code/firebaseTest folder. Either provide one or
disable Service Worker in your angular.json configuration file.

我看着我的angular.json,发现在这一行:

"ngswConfigPath": "/src/ngsw-config.json",

Property ngswConfigPath is not allowed.

我找不到新的angular.json的api,但似乎我需要以不同的方式指定路径.

ng update @ angular / pwa也没有用.

我该如何解决这个错误

解决方法

我不知道“ngswConfigPath”:“/ src / ngsw-config.json”是如何被添加的,但是我删除它并且它构建得很好.

我遇到的下一个问题是,在升级过程中,ngsw-config.json已从src移出并移至项目根目录.我必须将我的更新复制到root ngsw-config.json中,以便服务工作者正确注册.

猜你在找的Angularjs相关文章