1

enter image description herehave some error with httpclientmodule: i have app.module.ts and there is code :

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';
import { AppComponent }   from './app.component';
import {HttpClientModule  } from '@angular/http';

@NgModule({
    imports:      [ BrowserModule, FormsModule, HttpClientModule  ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
export class AppModule { }

and error: nodemodules/@angular/http/http has no exported member 'HttpClientModule'

shoopik
  • 309
  • 2
  • 5
  • 15
  • see [Difference between HTTP and HTTPClient in angular 4?](https://stackoverflow.com/questions/45129790/difference-between-http-and-httpclient-in-angular-4/45129865#45129865) – Max Koretskyi Aug 02 '17 at 10:59

1 Answers1

4

It should be imported from @angular/common/http

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

Make sure you have installed angular@^4.3.0 (changelog)

See also the docs

Plunker Example

yurzui
  • 205,937
  • 32
  • 433
  • 399
  • i tried it, but there is error: cannot find module '@angular/common/http' – shoopik Aug 02 '17 at 08:24
  • @shoopik Which angular version are you using? – yurzui Aug 02 '17 at 08:25
  • mm, how can i check it ? in json i see next: "@angular/common": "~4.0.0", "@angular/compiler": "~4.0.0", – shoopik Aug 02 '17 at 08:28
  • @shoopik You have to upgrade your version – yurzui Aug 02 '17 at 08:29
  • can you tell me how to do it ?)) – shoopik Aug 02 '17 at 08:31
  • Replace all `"~4.0.0"` with `"~4.3.0"`. Remove `node_modules` folder and run `npm i` – yurzui Aug 02 '17 at 08:32
  • now i have errors with system.js, before update that was ok – shoopik Aug 02 '17 at 09:01
  • @shoopik Check `config.js` from https://plnkr.co/edit/foQNdnt5CRmzpnBuInfT or config from my repo https://github.com/alexzuza/angular2-typescript-systemjs/blob/master/systemjs.config.js – yurzui Aug 02 '17 at 09:01
  • oh, still have errors, but when i delete httpcliendmodue it works – shoopik Aug 02 '17 at 09:07
  • Try adding `'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',` and `'tslib': 'npm:tslib/tslib.js',` – yurzui Aug 02 '17 at 09:12
  • i dont know whats wrong, but there is bunch of errors with zone.js – shoopik Aug 02 '17 at 12:09
  • @shoopik I need some reproduction. Maybe you can setup minimal github repo? – yurzui Aug 02 '17 at 12:23
  • i delete systemjs.config and now it works without httpclientmodule, and dont with it – shoopik Aug 02 '17 at 12:30
  • by the way, i put my config.js because it works without httpclientmodule, when i put your config.js it doesnt work even wtihout – shoopik Aug 02 '17 at 12:35
  • 1
    @shoopik I don't see where you added `'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js'`, and `'tslib': 'npm:tslib/tslib.js'` Don't forget `npm i --save tslib`. After that your repo works for me – yurzui Aug 02 '17 at 12:39
  • thank you!!!!!!!!!!!!!!!!!!! but why it worked without tslib when i didnt type httpclientmodule, how is it depends – shoopik Aug 02 '17 at 12:43
  • 1
    `common-http.umd.js` bundle requires it as dependency. Maybe it will be changed soon https://github.com/angular/common-builds/blob/4.3.0/bundles/common-http.umd.js#L7 – yurzui Aug 02 '17 at 12:49