angular-cli: Error adding `@angular/pwa` v0.7.0-rc.3

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [x] add

Versions

> node --version
v8.11.3

> npm --version
5.6.0

> ng --version
Angular CLI: 6.1.0-rc.3
Node: 8.11.3
OS: win32 x64
Angular: 6.0.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.0-rc.3
@angular-devkit/build-angular     0.7.0-rc.3
@angular-devkit/build-optimizer   0.7.0-rc.3
@angular-devkit/build-webpack     0.7.0-rc.3
@angular-devkit/core              0.7.0-rc.3
@angular-devkit/schematics        0.7.0-rc.3
@angular/cli                      6.1.0-rc.3
@angular/pwa                      0.7.0-rc.3
@ngtools/webpack                  6.1.0-rc.3
@schematics/angular               0.7.0-rc.3
@schematics/update                0.7.0-rc.3
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

OS: Windows 10

Repro steps

  1. npm install --global @angular/cli@next
  2. ng new test-app
  3. cd test-app
  4. ng add @angular/pwa@next --project=test-app

The log given by the failure

Installing packages for tooling via npm.
+ @angular/pwa@0.7.0-rc.3
added 2 packages in 12.443s
Installed packages for tooling via npm.
Path "/ngsw-config.json" already exist.

Npm dependencies are updated (including package.json and package-lock.json), but the add command is not completed (no ngsw-config.json, no manifest.json, no changes in index.html, etc).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 26
  • Comments: 48 (9 by maintainers)

Most upvoted comments

This seems to have been fixed (by #11655) and works fine with the beta versions:

  • @angular/cli@next (v6.2.0-beta.1)
  • @angular-devkit/build-angular@next (v0.8.0-beta.0)
  • @angular/pwa@next (v0.8.0-beta.1)

https://github.com/ducdung8491/angular-cli/blob/master/packages/angular_devkit/core/src/virtual-fs/host/memory.ts#L197

Khi tạo ngsw-config.json phương thức _rename(from, to) của SimpleMemoryHost có check to trên _cache, vì nó đã tồn tại nên có ngoại lệ FileAlreadyExistException

ng add @angular/pwa@0.6.8 --project <name project as package.json>

It works for me, from #11663

I faced the same problem with the latest CLI.

> ng -v
Angular CLI: 6.1.0
Node: 8.9.4
OS: darwin x64
Angular: 6.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.0
@angular-devkit/build-angular     0.7.0
@angular-devkit/build-optimizer   0.7.0
@angular-devkit/build-webpack     0.7.0
@angular-devkit/core              0.7.0
@angular-devkit/schematics        0.7.0
@angular/pwa                      0.7.0
@ngtools/webpack                  6.1.0
@schematics/angular               0.7.0
@schematics/update                0.7.0
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2
$ ng add @angular/pwa --project=my-app
Installing packages for tooling via npm.
+ @angular/pwa@0.7.0
updated 1 package and audited 29133 packages in 10.227s
found 13 vulnerabilities (9 low, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Installed packages for tooling via npm.
Path "/ngsw-config.json" already exist.

I confirm: it works with

npm install @angular/cli@next -g
...
ng add @angular/pwa@next

Version info:

Angular CLI: 6.2.0-beta.2
Node: 8.11.3
OS: darwin x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.0-beta.2
@angular-devkit/build-angular     0.8.0-beta.2
@angular-devkit/build-optimizer   0.8.0-beta.2
@angular-devkit/build-webpack     0.8.0-beta.2
@angular-devkit/core              0.8.0-beta.2
@angular-devkit/schematics        0.8.0-beta.2
@angular/cli                      6.2.0-beta.2
@angular/pwa                      0.8.0-beta.2
@ngtools/webpack                  6.2.0-beta.2
@schematics/angular               0.8.0-beta.2
@schematics/update                0.8.0-beta.2
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.16.5

This is still an issue after the CLI 6.1.1 release.

its not fixed on version 0.7.1 on #11655 problem still exists with a fresh project and on adding existing projects

Possibly fixed by #11655.

@batbrain9392 you also need to use cli v6.0.8.

Dispersia, this issue have reference to issues number 11465, 11666, 11662, 11663, 11655, 11839. Every of this issues have references too. We jump from issue to issue and back, and we see how are they “closed”, but the issue was not really solved.

No, issue is not solved - I tried it yesterday (without tricks as downgrade and beta versions (because it can cause some another problem - I want to have libraries actual)) and the result was in my prev comment.

@bamboozooled : Yeah, I could…

  1. npm i -g @angular/cli@6.0.8
  2. ng new projectName
  3. ng add @angular/pwa@0.6.8

Someone kindly look into this asap. Thanks.

For anyone looking for a workaround, you may rollback to @angular/cli@~6.0.0 with @angular/pwa@~0.6.0.

Thank you abhishek1716! I’ve been struggling with this for a couple hours. Working solution for a mess of a problem.

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 @angular/cli@6.0.8 ng add @angular/pwa 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

@gkalpak The issue is that since around CLI v 6.1.0 various commands that used to work just don’t. ng g c, ng g m, this one etc. We do downgrades and upgrades of CLI to get different parts working, delete and reinstall node_modules; for some that works, for some it doesn’t. It is like real alchemy to get something working and overall it is frustrating. I seriously regret updating to CLI 6.1.1, that’s when my problems started.

Now this issue is closed and suggestion is - as I understand it - to make basically Sophie’s choice between PWA and Material.

Don’t get me wrong, I really appreciate CLI. Usually it does very good job and is great help at routine tasks. Just recently way too many frequently used commands and functionality seems to be broken and there is no way in stable releases get all that sweet functionality working 😦

Sorry about the rant probably just needed to vent the frustration.

Same issues.

and, another project with PWA:

ng g m consumer

Error:

newTree.optimize is not a function