4

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

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
Pooja Patel
  • 89
  • 3
  • 9
  • Make sure you specified the version number in your call to ng add @angular/pwa as Jesus Sandrea suggested. – Markus S. Jul 29 '18 at 16:47

5 Answers5

15

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

Jesus Sandrea
  • 335
  • 2
  • 4
  • 14
  • thanks, but no need to install a clean project, just CLI 6.0.8 and @angular/pwa@0.6.8 worked for me – Elger Mensonides Aug 04 '18 at 18:14
  • This seemingly little things, but deal breakers are the things that make Angular not get a good name among many and some end up hating it. What nonsense is this? My current version is 6.1.2, and since 6.0.8, the core team hasn't bothered fixing this show stopper? How do the many embrace the all so preached PWA when the framework itself is broken in that regard? – KhoPhi Aug 07 '18 at 16:44
  • 1
    I was running CLI version 6.1.0 and experiencing the same issue. This now seems to have been resolved in CLI 6.1.5 – PhatBuck Sep 05 '18 at 09:28
5

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"
sksvenson
  • 61
  • 4
1

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
Shubham Yadav
  • 43
  • 1
  • 4
Vtf Media
  • 11
  • 2
0

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

Sim_on
  • 164
  • 1
  • 11
0
 npm i @angular/cli@6.0.8

 npm add @angular/pwa@6.0.8

it will be ok

Joy Zhou
  • 1
  • 1