The update went fine, but now when I build, I get the following error.
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.
I looked in my angular.json
and found that on this line:
"ngswConfigPath": "/src/ngsw-config.json",
Property ngswConfigPath is not allowed.
I can't find an api for the new angular.json, but it seems as if I need to specify the path in a different way.
ng update @angular/pwa
didn't work either.
How can I resolve this error?
Please make sure to build your app in root folder. I had the same issue and building from the root folder solved my issue.
I'm not sure how "ngswConfigPath": "/src/ngsw-config.json"
, was added, but I removed it and it built fine.
Next issue I faced was that ngsw-config.json
has been moved out of src
and to the project root during the upgrade. I had to copy my updates into the root ngsw-config.json
for the service worker to register properly.
对于我的案例问题与在路径前面添加的/
符号有关,因此我使用了"ngswConfigPath": "src/ngsw-config.json"
"ngswConfigPath": "/src/ngsw-config.json"
而不是"ngswConfigPath": "/src/ngsw-config.json"
"ngswConfigPath": "src/ngsw-config.json"
并解决了问题。
Actually the file ngsw-config.json is generated but is on a different location. First disable Service Worker in your angular.json/angular-cli.json configuration file. Then run ng build --prod
on your terminal. It should run without errors.
Then enable the service worker in your angular.json/angular-cli.json and run the ng build --prod
command again in your terminal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.