I have created a new angular project. Then I add
ng add @angular/pwa
I got an error like this even I can't find the ngsw-config.json file
Path "/ngsw-config.json" already exist.
In angular CLI version is 6.1.1.
Invalid rule result: Function().
In angular CLI version is 6.0.3
Try to install the CLI version 6.0.8 and then install in a clean project try ng add @angular/pwa@0.6.8
Seems like the error hasn't been solved by the core team so in the meanwhile we have to use a lower version
I had the same issue. I came from Angular 5 and updated to Angular 6.
I use these specific versions to get it work:
npm install --save @angular/cli@6.0.8
npm install --save @angular/pwa@0.6.8
And I had also to remove this entry from angular.json:
"ngswConfigPath": "src/ngsw-config.json"
When you move your @angular/cli version to 6.0.8 then you will face another issue while adding ng add @angular/material ------- to add both the latest Angular Material and PWA into your project Please read below.
This is just the turnaround after reading many slackoverflow and github solution. I was successfully able to add angular material when my @angular/cli was at version 6.1.2 --> then to add Pwa I downgrade the @angular/cli version to 6.0.8 and after I successfully added PWA again I upgraded the @angular/cli to next version v6.2.0-beta.1 then I upgraded my angular/core and angular/material.
My cli code-
**
> npm install --save @angular/cli@6.1.2
> ng new project
> ng add @angular/material
> npm install --save-dev @angular/cli@6.0.8
> ng add @angular/pwa --project <project_name>
> npm install --save @angular/cli@next
> ng update @angular/core
> ng update @angular/material
**
Hope this workaround works for you.
My Version at the moment
@angular/cli - 6.2.0-beta.1
@angular/material & @angular/cdk - 6.4.3
@angular/pwa - 0.6.8
Can you post your angular.json here?
I had the problem that I had defined "configurations: {...}"
in my angular.json file. After removing it I was able ng add @angular/pwa
npm i @angular/cli@6.0.8
npm add @angular/pwa@6.0.8
it will be ok
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.