繁体   English   中英

src/app/app.module.ts:38:5 中的错误 - 错误 TS2304:找不到名称 'HttpClientModule'

[英]ERROR in src/app/app.module.ts:38:5 - error TS2304: Cannot find name 'HttpClientModule'

我将 Angular-8 用于特定项目。

这是我的 app.module.ts

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { LoginModule } from './login/login.module';
import { CoreModule } from './core/core.module';
import { SharedModule } from './shared/shared.module';
import { ReactiveFormsModule } from '@angular/forms';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { ErrorsModule } from './errors/errors.module';
import { RouterModule } from '@angular/router';
import { PagesModule } from './pages/pages.module';
import { FormsModule } from '@angular/forms';
import { SidebarComponent } from './shared/sidebar/sidebar.component';
import { StoreModule } from '@ngrx/store';
import { reducers, metaReducers } from './store/reducers';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../environments/environment';
import { EffectsModule } from '@ngrx/effects';
import { AppEffects } from './store/effects/app.effects';
import { JwtInterceptor } from './core/interceptors/jwt.interceptor';
import { ErrorInterceptor } from './core/interceptors/error.interceptor';
import { CacheInterceptor } from './core/interceptors/cache.interceptor';
import { ServiceWorkerModule } from '@angular/service-worker';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import {HttpClientModule} from '@angular/common/http';

@NgModule({
 imports: [
  RouterModule,
  BrowserModule,
  BrowserAnimationsModule,
  LoginModule,
  CoreModule,
  SharedModule,
  ReactiveFormsModule,
  HttpClientModule,
  ErrorsModule,
  PagesModule,
  FormsModule,
  AppRoutingModule,
  StoreModule.forRoot(reducers, {
    metaReducers,
    runtimeChecks: {
      strictStateImmutability: true,
      strictActionImmutability: true
    }
  }),
  !environment.production ? StoreDevtoolsModule.instrument() : [],
  EffectsModule.forRoot([AppEffects]),
  StoreDevtoolsModule.instrument({
    maxAge: 25,
    logOnly: environment.production
  }),
  ServiceWorkerModule.register('ngsw-worker.js', {
    enabled: environment.production
  })
],

当我做 ng 服务时,我收到了这个错误:

src/app/app.module.ts:38:5 中的错误 - 错误 TS2304:找不到名称“HttpClientModule”。

这是第 38 行:

HttpClient模块,

我该如何解决这个问题?

谢谢

Angular 4.3.0版本引入了HttpClient。 此外,您必须确保在主 AppModule 的导入元数据中导入并注入了 HttpClientModule。

 // Import HttpClientModule from @angular/common/http in AppModule import {HttpClientModule} from '@angular/common/http'; //in place where you wanted to use `HttpClient` import { HttpClient } from '@angular/common/http';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM