如何修复 Angular 'ng update' 后的 Cannot find module '@angular/http'
更新到 Angular 8.x+ 时,开发者通常遇到此类错误:
angular_http_deprecation_error.txt
app/app.module.ts:9:42 - error TS2307: Cannot find module '@angular/http'.
9 import {HttpModule, RequestOptions} from '@angular/http';解决方案
@angular/http 模块在最近版本的 Angular 中已被移除,由 @angular/common/http 替代。此外,有一些名称更改可能需要手动修复,包括:
HttpModule⇒HttpClientModuleHttp⇒HttpClientURLSearchParams⇒HttpParams
注意替换并不总是完全等价,因此可能需要一些工作才能使其工作
请参见官方的 @angular/http 弃用指南获取有关如何迁移的更多详细信息。
Check out similar posts by category:
Allgemein
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow