angular-cli: Angular CLI 1.5.0-rc.6 does not support @angular/service-worker@5.0.0-rc.8

Bug Report or Feature Request (mark with an x)

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

Versions.

ng -v

Angular CLI: 1.5.0-rc.6 Node: 8.5.0 OS: win32 x64 Angular: 5.0.0-rc.8 … animations, common, compiler, compiler-cli, core, forms … http, platform-browser, platform-browser-dynamic … platform-server, router

@angular/cdk: 2.0.0-beta.12 @angular/cli: 1.5.0-rc.6 @angular/material: 2.0.0-beta.12 @angular/service-worker: 5.0.0-rc.8 @angular-devkit/build-optimizer: 0.0.31 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.34 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0-rc.6 @schematics/angular: 0.0.48 typescript: 2.5.3 webpack: 3.8.1

Repro steps.

ng build --prod --aot --base-href=.

The log given by the failure.

**Build fails with error: **

The installed version of @angular/service-worker is 5.0.0-rc.8. This version of the CLI requires the @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0. Please upgrade your service worker version. Error: The installed version of @angular/service-worker is 5.0.0-rc.8. This version of the CLI requires the @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0. Please upgrade your service worker version.

Desired functionality.

The newest @angular/cli isn’t compatible with any of the new @angular/service-worker versions; which it should.

Mention any other details that might be useful.

The old version of @angular/service-worker is working, 1.0.0-beta.16.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 22
  • Comments: 18 (4 by maintainers)

Most upvoted comments

There is no built-in support for service worker in 1.5. But since the @angular/service-worker package has its cli separate you can use it with 1.5. There is a good explanation for this by @webmaxru here and here. Just make sure to remove the service-worker entry from the .angular-cli.json, because this will cause a fatal error.

I now have cli 1.6.0-rc.0 and confirm that without "serviceWorker": true in the .angular-cli.json file DOES resolve the issue.

@dalu this is fixed in the upcoming 1.6 You can try 1.6.0-rc.2 if you want (first release with the fix).

I’m not an authority on this topic, but https://github.com/angular/angular-cli/issues/8224 seems to indicate that it would be part of 1.6.0. Based on the rapid rate of development on the CLI, I don’t think that will be a long wait.

Btw, the OP should probably be updated to a feature request instead of a bug as this was intended. Actually, this issue likely can be closed in favor of #8224.

Also documentation on @angular/service-worker is lacking. Even angular.io doesn’t use it yet so no surprises here.

I think there is still an issue with 1.6.0-rc.1.

If you try to use @angular/service-worker in 5.1.0-rc.1 for example, you run into:

The installed version of @angular/service-worker is 5.1.0-rc.1. This version of the CLI
requires the @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0. Please upgrade
your service worker version.

whereas using 5.0.5 everything is fine.

Update: looks like the CLI check uses semver.satisfies which will fail for RC and betas. I’m opening a PR to start a discussion on using gt() instead.

Hello All ~

I am having the same issue even after trying what @johanchouquet said. I have "serviceWorker": true in my .angular-cli.json file yet I still get this error when trying to build:

The installed version of @angular/service-worker is 5.1.0-beta.2. This version of the CLI
requires the @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0. Please upgrade
your service worker version.

Here is my ng -v info:

Angular CLI: 1.6.0-rc.1-930437e
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0-beta.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.6.0-rc.1-930437e
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.38
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0-rc.1-930437e
@schematics/angular: 0.1.8
typescript: 2.6.2
webpack: 3.8.1

Please let me know if there is anyway around this. Thanks!

Likewise #8080.