Angular-cli: ng add @angular/pwa fails with 'Invalid rule result: Function().'

Created on 26 Jul 2018  Â·  14Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [x] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node --version
v10.2.1
ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.8
Node: 10.2.1
OS: darwin 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.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@angular/pwa                      0.7.0
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.8.3
npm --version
6.2.0

Repro steps

ng new projectName --routing --prefix=prfx --style=scss && cd projectName && ng add @angular/pwa

The log given by the failure

ng add @angular/pwa
Installing packages for tooling via npm.
+ @angular/[email protected]
updated 1 package and audited 26697 packages in 6.57s
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.
Invalid rule result: Function().

Mention any other details that might be useful

schematicangular high broken bufix non-obvious

Most helpful comment

You should to use @angular/[email protected]. Goodluck!

All 14 comments

@mruknowme Do you have a solution yet. Am having the same issue.

Same problem here. 6.1.0 doesnt work either (different error). I tried to downgrade and got this.

You should to use @angular/[email protected]. Goodluck!

Sounds similar to #11640 (although the error message is different).

This is due to a new feature in Schematics that you can now return a Rule in a Schematics. Unfortunately, that means some Schematics are not backward compatible.

We will release a patch that will fix this, but in the meantime you can update @angular-devkit/schematics to 0.7.0 and it will fix the issue.

@hansl after updating now I get "Path "/ngsw-config.json" already exist."

Same problem, i thing there is bugs in [email protected], you need to use lower version, after that works fine

@hansl I am using @angular-devkit/schematics 0.7.1. I still get same error. @odineshrao I tried installing lower version [email protected] but still get same error. Do you know which lower version work proper?

@odineshrao 0.6.8 worked.

Hi guys, with 0.6.8 version I get newTree.optimize is not a function . I couldn't find a solution to this, does anybody have any idea?

The solutions that worked for me in the end was from sksvenson https://stackoverflow.com/questions/51555017/path-ngsw-config-json-already-exists

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/[email protected]
npm install --save @angular/[email protected]

And I had also to remove this entry from angular.json:

"ngswConfigPath": "src/ngsw-config.json"

The solution that worked for me is to downgrade to version 6.0.0.

none of these solution works. how come when i do ng g c cname i get Invalid rule result: Function().

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings