将 Angular 4.4 更新到 5.2 后出现意外的 EventSource 请求
Unexpected EventSource requests after updating Angular 4.4 to 5.2
我正在尝试将正在开发的 Web 应用程序迁移到 Angular 5.2。
按照 https://angular-update-guide.firebaseapp.com/ 上的说明进行操作,
我已经能够像往常一样使用'ng serve -lr'在开发模式下运行应用程序。
但是,在应用程序启动后,未在 Angular 4.4 上触发的多个 HTTP 请求正在执行,最终 webpack-dev-server 断开连接。
我的 package.json 在 Angular 4.4 上,更新前:
"dependencies": {
"@agm/core": "^1.0.0-beta.1",
"@angular/animations": "^4.4.0-RC.0",
"@angular/cdk": "^2.0.0-beta.10",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": "^4.4.4",
"@angular/http": "^4.4.4",
"@angular/material": "^2.0.0-beta.10",
"@angular/platform-browser": "^4.4.4",
"@angular/platform-browser-dynamic": "^4.4.4",
"@angular/router": "^4.4.4",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"@types/jquery": "^3.2.12",
"angular2-multiselect-dropdown": "^1.3.6",
"angular2-text-mask": "^8.0.4",
"autoprefixer": "^7.1.1",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"moment": "^2.19.1",
"ng2-daterangepicker": "^2.0.12",
"rxjs": "^5.1.0",
"tinymce": "^4.6.7",
"zone.js": "^0.8.4"
}, "devDependencies": {
"@angular/cli": "1.4.5",
"@angular/compiler-cli": "^4.4.4",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"concurrently": "^3.4.0",
"htmlhint-ng2": "0.0.13",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"json-server": "^0.10.1",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"sass-lint": "latest",
"scss-lint": "0.0.0",
"scss-lint-html-reporter": "^0.3.2",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
},
"sasslintConfig": "sass-lint.yml"
}
package.json 更新到 angular 5.2 后:
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^5.2.3",
"@angular/cdk": "^5.1.1",
"@angular/common": "^5.2.3",
"@angular/compiler": "^5.2.3",
"@angular/core": "^5.2.3",
"@angular/forms": "^5.2.3",
"@angular/http": "^5.2.3",
"@angular/material": "^5.1.1",
"@angular/platform-browser": "^5.2.3",
"@angular/platform-browser-dynamic": "^5.2.3",
"@angular/platform-server": "^5.2.3",
"@angular/router": "^5.2.3",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"@types/jquery": "^3.2.12",
"angular2-multiselect-dropdown": "^1.3.6",
"angular2-text-mask": "^8.0.4",
"autoprefixer": "^7.2.5",
"bootstrap": "^4.0.0",
"core-js": "^2.5.3",
"file-loader": "^1.1.6",
"jquery": "^3.2.1",
"lodash": "^4.17.5",
"mixpanel-browser": "^2.17.0",
"moment": "^2.19.1",
"ng2-daterangepicker": "^2.0.12",
"node-sass": "^4.7.2",
"popper.js": "^1.12.9",
"rxjs": "^5.5.6",
"tinymce": "^4.7.6",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular/cli": "^1.6.7",
"@angular/compiler-cli": "^5.2.3",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.96",
"codelyzer": "^4.1.0",
"concurrently": "^3.5.1",
"htmlhint-ng2": "0.0.13",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"json-server": "^0.10.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"sass-lint": "latest",
"scss-lint": "0.0.0",
"scss-lint-html-reporter": "^0.3.2",
"ts-node": "~2.0.0",
"tslint": "^5.9.1",
"typescript": "^2.6.2",
"webpack": "^3.10.0"
},
"sasslintConfig": "sass-lint.yml"
}
Unexpected requests in the network tab of Chrome Dev Tools
Browser console errors
Similar issue posted on angular-cli GitHub page
似乎问题出在 webpack 实时重新加载中。通过向启动脚本添加参数来解决它,现在是
ng serve --public-host http://localhost:4200/ -lr
我正在尝试将正在开发的 Web 应用程序迁移到 Angular 5.2。
按照 https://angular-update-guide.firebaseapp.com/ 上的说明进行操作,
我已经能够像往常一样使用'ng serve -lr'在开发模式下运行应用程序。
但是,在应用程序启动后,未在 Angular 4.4 上触发的多个 HTTP 请求正在执行,最终 webpack-dev-server 断开连接。
我的 package.json 在 Angular 4.4 上,更新前:
"dependencies": {
"@agm/core": "^1.0.0-beta.1",
"@angular/animations": "^4.4.0-RC.0",
"@angular/cdk": "^2.0.0-beta.10",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": "^4.4.4",
"@angular/http": "^4.4.4",
"@angular/material": "^2.0.0-beta.10",
"@angular/platform-browser": "^4.4.4",
"@angular/platform-browser-dynamic": "^4.4.4",
"@angular/router": "^4.4.4",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"@types/jquery": "^3.2.12",
"angular2-multiselect-dropdown": "^1.3.6",
"angular2-text-mask": "^8.0.4",
"autoprefixer": "^7.1.1",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"moment": "^2.19.1",
"ng2-daterangepicker": "^2.0.12",
"rxjs": "^5.1.0",
"tinymce": "^4.6.7",
"zone.js": "^0.8.4"
}, "devDependencies": {
"@angular/cli": "1.4.5",
"@angular/compiler-cli": "^4.4.4",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"concurrently": "^3.4.0",
"htmlhint-ng2": "0.0.13",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"json-server": "^0.10.1",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"sass-lint": "latest",
"scss-lint": "0.0.0",
"scss-lint-html-reporter": "^0.3.2",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
},
"sasslintConfig": "sass-lint.yml"
}
package.json 更新到 angular 5.2 后:
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^5.2.3",
"@angular/cdk": "^5.1.1",
"@angular/common": "^5.2.3",
"@angular/compiler": "^5.2.3",
"@angular/core": "^5.2.3",
"@angular/forms": "^5.2.3",
"@angular/http": "^5.2.3",
"@angular/material": "^5.1.1",
"@angular/platform-browser": "^5.2.3",
"@angular/platform-browser-dynamic": "^5.2.3",
"@angular/platform-server": "^5.2.3",
"@angular/router": "^5.2.3",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"@types/jquery": "^3.2.12",
"angular2-multiselect-dropdown": "^1.3.6",
"angular2-text-mask": "^8.0.4",
"autoprefixer": "^7.2.5",
"bootstrap": "^4.0.0",
"core-js": "^2.5.3",
"file-loader": "^1.1.6",
"jquery": "^3.2.1",
"lodash": "^4.17.5",
"mixpanel-browser": "^2.17.0",
"moment": "^2.19.1",
"ng2-daterangepicker": "^2.0.12",
"node-sass": "^4.7.2",
"popper.js": "^1.12.9",
"rxjs": "^5.5.6",
"tinymce": "^4.7.6",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular/cli": "^1.6.7",
"@angular/compiler-cli": "^5.2.3",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.96",
"codelyzer": "^4.1.0",
"concurrently": "^3.5.1",
"htmlhint-ng2": "0.0.13",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"json-server": "^0.10.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"sass-lint": "latest",
"scss-lint": "0.0.0",
"scss-lint-html-reporter": "^0.3.2",
"ts-node": "~2.0.0",
"tslint": "^5.9.1",
"typescript": "^2.6.2",
"webpack": "^3.10.0"
},
"sasslintConfig": "sass-lint.yml"
}
Unexpected requests in the network tab of Chrome Dev Tools
Browser console errors
Similar issue posted on angular-cli GitHub page
似乎问题出在 webpack 实时重新加载中。通过向启动脚本添加参数来解决它,现在是
ng serve --public-host http://localhost:4200/ -lr