1

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?

7
  • did you try to restart your IDE? Commented Sep 8, 2017 at 8:21
  • @smnbbrv I restated my computer, but still does not work. Commented Sep 8, 2017 at 8:23
  • maybe a stupid question but did you run npm update? Commented Sep 8, 2017 at 8:25
  • @smnbbrv off course, I install npm update package and then run the ncu -u. All the packages updated automatically. Commented Sep 8, 2017 at 8:26
  • 1
    then just go to those file and check whether the HttpClientModule is exported there... Commented Sep 8, 2017 at 8:30

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

In your module.ts

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

It should work

1 Comment

It is existed in module.ts but nothing. Please see the picture I added up.
0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.