Ionic 4 -> ng add @angular/pwa

If you are experiencing issues when running ng add @angular/pwa using the latest version of the Angular CLI (6.1.x), for example:

ng add @angular/pwa
Error: Path "/ngsw-config.json" already exist.

Try:

npm install --save-dev @angular/cli@next
npm install --save-dev @angular-devkit/build-angular@next
npm install --save @angular/pwa@next

ng add @angular/pwa@next

Note: Make sure your project name is the same in ‘package.json’ (“name”: “Brew”) and ‘angular.json’ (“defaultProject”: “Brew”).

See: https://github.com/angular/angular-cli/issues/11640#issuecomment-410638864

3 Likes

Even that is not working right now. The cli version mentioned in package.json is too low. By default the cli version as of now do not accept add command. Have to update with @latest version name.
I did npm i @angular/cli@7.0.5 but the cli mentioned in package.json is 6.1 and that is the default cli version.