Angular中的HttpClient模块出现错误 [英] Getting Error with HttpClient Module in angular
问题描述
node_modules/@angular/common/http/http.d.ts:81:22中的错误-错误NG6002:出现在AppModule的NgModule.imports中,但无法解析为NgModule类.
ERROR in node_modules/@angular/common/http/http.d.ts:81:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
这可能意味着声明HttpClient
的库(@angular/common/http
)未被ngcc
正确处理,或者
与Angular Ivy
不兼容.检查是否有较新版本的库,如果有,则进行更新.还可以考虑与图书馆的作者进行核对,以查看该图书馆是否与Ivy兼容.
This likely means that the library (@angular/common/http
) which declares HttpClient
has not been processed correctly by ngcc
, or
is not compatible with Angular Ivy
. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
81导出声明类HttpClient {
81 export declare class HttpClient {
推荐答案
也许您已导入HttpClient
而不是HttpClientModule
.
检查app.module.ts
Maybe you have imported HttpClient
instead ofHttpClientModule
.
Check imports in app.module.ts
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatToolbarModule,
FlexLayoutModule,
HttpClientModule
],
这篇关于Angular中的HttpClient模块出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!