angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open gkalpak opened this issue 8 years ago • 48 comments

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/[email protected]
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).

gkalpak avatar Jul 24 '18 12:07 gkalpak

ng add @angular/[email protected] --project <name project as package.json>

It works for me, from #11663

virkinia avatar Jul 31 '18 07:07 virkinia

@virlliNia : I tried what u specified.

Project name in package.json : ng-universal ng add @angular/[email protected] --project ng-universal Error : Project 'ng-universal' could not be found in workspace.

Project name in angular.json : ngUniversal ng add @angular/[email protected] --project ngUniversal Error : Data path "" should NOT have additional properties(title).

batbrain9392 avatar Jul 31 '18 12:07 batbrain9392

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

alexandremoore avatar Jul 31 '18 15:07 alexandremoore

@virlliNia after folloeing your suggestion , i also followed @alexandremoore, and then it fixed my issue.

ghost avatar Aug 01 '18 18:08 ghost

@batbrain9392 were you able to fix it? Having same issue.

oluwatimio avatar Aug 05 '18 20:08 oluwatimio

@bamboozooled : Yeah, I could..

  1. npm i -g @angular/[email protected]
  2. ng new projectName
  3. ng add @angular/[email protected]

batbrain9392 avatar Aug 06 '18 07:08 batbrain9392

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)

gkalpak avatar Aug 06 '18 09:08 gkalpak

@gkalpak : Although pwa works, since this version has new changes in angular.json, ng add @angular/material does not work. Error : Your project is not using the default configuration for build and test. The Angular Material schematics can only be used with the default configuration.

batbrain9392 avatar Aug 06 '18 09:08 batbrain9392

@batbrain9392: That is totally unrelated to the current issue. Feel free to open a new one, if you think there is something broken with @angular/material.

gkalpak avatar Aug 06 '18 09:08 gkalpak

@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.

PeS82 avatar Aug 06 '18 14:08 PeS82

Sorry to hear you are frustrated 😞

Just to be clear, there is no suggestion to choose between PWA and material. Both should work (and if they don't, they need to be fixed).

This issue was about @angular/pwa not working with latest cli. This problem has been fixed.

If there is also a problem with @angular/material (I'm not aware of that), please open a new issue. That way, the cli team will be aware of that and fix it too \o/

gkalpak avatar Aug 06 '18 15:08 gkalpak

@PeS82 Please also note that the error shown above and caused by ng add @angular/material, is actually generated by material itself and not the CLI. The relevant code is here: https://github.com/angular/material2/blob/master/src/lib/schematics/install/theming.ts#L26

clydin avatar Aug 06 '18 15:08 clydin

I know there was no explicit suggestion to choose between PWA and Material. But based on @batbrain9392 comment I understand it that I can get adding PWA working by updating to versions you mentioned but since the angular.json structure is changed I cannot add material later. At least for the moment being.

Today I spent couple of hours diffing angular.json of project updated from Angular 5.x and new one trying to figure out why in the old one ng g c|m doesn't work while in the new one does. Couldn't find any difference in installed versions or config.

So I decided to move on and add PWA to the new project and work there and found out I can't. And that threw me over the top (if that means in English what I think it means) 😀

It is good to hear that this issue is fixed, however the overall experience lately is really frustrating.

Just ignore me, maybe it's the never-ending heat this summer that got me too, switching PC off and going to swim, maybe it will help 😁

PeS82 avatar Aug 06 '18 15:08 PeS82

@batbrain9392 Did not still work. I had to eventually add pwa functionality manually as adding @angular/pwa does not work in my existing app.

oluwatimio avatar Aug 06 '18 17:08 oluwatimio

A lot of circular references between issues because of 'duplicate'. It looks like finding similar problem between issues is solution, then issue closed. Please, do not enter wanna be - not tested solutions and information about may be "duplicate issue" and close. When you solve problem, then close all issues about problem. We now have to click between issues without finding solution.

b-mi avatar Aug 09 '18 09:08 b-mi

@b-mi what are you referring to? All issues should point to this one, that got fixed, and is now closed.

Dispersia avatar Aug 09 '18 18:08 Dispersia

Dispersia, circular references to issues are here in common.

This issue is not fixed:

During standard installing (not beta versions): ng add @angular/pwa

  • @angular/[email protected] added 5 packages in 13.831s Installed packages for tooling via npm. Could not find index file for the project

ng add @angular/material

  • @angular/[email protected] added 2 packages in 13.652s Installed packages for tooling via npm. Your project is not using the default configuration for build and test. The Angular Material schematics can only be used with the default configuration

Even, now looks like ng add @angular/material do not install @angular/cdk

ERROR in node_modules/@angular/material/autocomplete/typings/autocomplete-trigger.d.ts(8,32): error TS2307: Cannot find module '@angular/cdk/bidi'. node_modules/@angular/material/autocomplete/typings/autocomplete-trigger.d.ts(9,56): error TS2307: Cannot find module '@angular/cdk/overlay'.

b-mi avatar Aug 09 '18 19:08 b-mi

How are any of those circular, nor do they have to deal with the issue that this issue was meant to address? And are those currently existing issues? Where are the issue number for them?

Dispersia avatar Aug 09 '18 19:08 Dispersia

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/[email protected] ng new project ng add @angular/material npm install --save @angular/[email protected] 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

abhishek1716 avatar Aug 09 '18 21:08 abhishek1716

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

sjohnson32 avatar Aug 09 '18 21:08 sjohnson32