简体   繁体   English

Straatup上的Angular CLI Service Worker错误

[英]Angular CLI service worker error on stratup

I started new Angular 8 project with those specs: 我以这些规格开始了新的Angular 8项目:

Angular CLI: 8.0.4
Node: 10.16.0
OS: darwin x64
Angular: 8.0.2

Angular PWA: 角度PWA:

ng add @angular/pwa

package.json 的package.json

  "dependencies": {
    "@angular/animations": "~8.0.1",
    "@angular/common": "~8.0.1",
    "@angular/compiler": "~8.0.1",
    "@angular/core": "~8.0.1",
    "@angular/forms": "~8.0.1",
    "@angular/platform-browser": "~8.0.1",
    "@angular/platform-browser-dynamic": "~8.0.1",
    "@angular/pwa": "^0.800.4",
    "@angular/router": "~8.0.1",
    "@angular/service-worker": "~8.0.1",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },

I have 2 error in console on startup. 启动时控制台出现2错误。 How can I fix it? 我该如何解决?

A bad HTTP response code (404) was received when fetching the script. 提取脚本时收到错误的HTTP响应代码(404)。 service-worker.js.pre-build-optimizer.js:451 服务worker.js.pre - 构建 - optimizer.js:451

Service worker registration failed with: TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. 服务工作者注册失败,出现以下错误:TypeError:无法注册ServiceWorker:获取脚本时收到错误的HTTP响应代码(404)。

If you are trying to test this locally with the CLI, the service worker will throw this error. 如果您尝试使用CLI在本地进行测试,那么服务工作者将抛出此错误。 You need to test following these instructions . 您需要按照以下说明进行测试。

Further, if not on localhost, browsers reject service workers over insecure connections (http vs https) see here . 此外,如果不在本地主机上,浏览器会通过不安全的连接(http或https)拒绝服务工作者,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM