Node.js 错误:模块“AppModule”导入了意外值“HttpClient”。请添加@NgModule注释

Node.js 错误:模块“AppModule”导入了意外值“HttpClient”。请添加@NgModule注释,node.js,angular,cordova,uber-api,Node.js,Angular,Cordova,Uber Api,错误:模块“AppModule”导入了意外值“HttpClient”。请添加@NgModule注释 我不明白为什么我会犯这个错误 我试过两种方法: 从'@angular/common/http'导入{HttpClient}; 和 从'@angular/common/http'导入{HttpClientModule} 这是全部错误: Error: Unexpected value 'HttpClient' imported by the module 'AppModule'. Please add

错误:模块“AppModule”导入了意外值“HttpClient”。请添加@NgModule注释

我不明白为什么我会犯这个错误

我试过两种方法: 从'@angular/common/http'导入{HttpClient}; 和 从'@angular/common/http'导入{HttpClientModule}

这是全部错误:

Error: Unexpected value 'HttpClient' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (http://localhost:8100/build/vendor.js:116430:34)
at http://localhost:8100/build/vendor.js:131184:44
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/vendor.js:131159:49)
at JitCompiler._loadModules (http://localhost:8100/build/vendor.js:150357:87)
at JitCompiler._compileModuleAndComponents (http://localhost:8100/build/vendor.js:150318:36)
at JitCompiler.compileModuleAsync (http://localhost:8100/build/vendor.js:150212:37)
at CompilerImpl.compileModuleAsync (http://localhost:8100/build/vendor.js:115251:49)
at PlatformRef.bootstrapModule (http://localhost:8100/build/vendor.js:5952:25)
at Object.491 (http://localhost:8100/build/main.js:2405:109)
离子框架3.9.2 离子型本机:^2.9.0 爱奥尼亚应用程序脚本:3.2.4 角形磁芯:5.2.11 角度编译器CLI:5.2.11 节点:8.10.0
操作系统:Windows 10

您需要导入HttpClientModule,例如:

 import { HttpClientModule } from '@angular/common/http';

 @NgModule({
   imports: [
     BrowserModule,
     // import HttpClientModule after BrowserModule.
     HttpClientModule,
  ],
  declarations: [
     AppComponent,
  ],
  bootstrap: [ AppComponent ]
})

export class AppModule {}

阅读:

您需要导入HttpClientModule,例如:

 import { HttpClientModule } from '@angular/common/http';

 @NgModule({
   imports: [
     BrowserModule,
     // import HttpClientModule after BrowserModule.
     HttpClientModule,
  ],
  declarations: [
     AppComponent,
  ],
  bootstrap: [ AppComponent ]
})

export class AppModule {}
阅读: