找不到模块@angular/common/http Ionic 3 应用程序

Cannot find module @angular/common/http Ionic 3 app

我已经使用 ngx-translate 完成了 Ionic 3 应用程序的国际化。它给了我以下错误。

我已经使用 official doc here 做到了。

Cannot find module '@angular/common/http'

问题是 @angular/common/http 仅在 angular 4.3+ 中可用。但是在 Ionic 3 我们使用 Angular 4.1.3

所以这是解决方案:

我已经删除了@ngx-translate/http-loader

npm uninstall @ngx-translate/http-loader --save

并且添加它的旧版本:

npm i @ngx-translate/http-loader@0.1.0 --save

您可以阅读更多相关信息on Git

HttpClient 是在 Angular 4.3.0 中引入的,您正在使用 4.1.3。

在您使用的 Angular 版本中,您可以注入 Http(需要 HttpModule in imports: [...] of AppModule),但它具有不同的功能和一个不同的 API。