Yamur
Yamur

Reputation: 339

Cannot find module @angular/common/http even I have Angular 4.4.*

I have updated my angular packages versions as below.

enter image description here

I want to use import {HttpClientModule} from '@angular/common/http'; but I module could not found and even for httpClient also.

See below.

enter image description here

How could I fix this?

Upvotes: 1

Views: 2842

Answers (3)

Sajeetharan
Sajeetharan

Reputation: 222582

No the actual issue is with the stackblitz itself,

this is a known bug with type definitions in sub-packages, we have a fix coming for it soon. That code will actually work in the preview btw, it's just the red underline is incorrect!

Upvotes: 0

Yamur
Yamur

Reputation: 339

Thanks for the comments. I got the solution.

Actually, I don't know the main reason but the path of http under @angular/common is different in my case.

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

Then it works fine.

Upvotes: 1

Atlas
Atlas

Reputation: 241

In your module.ts

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

It should work

Upvotes: 0

Related Questions