Module not found: Error: Can't resolve 'http' in selenium-webdriver

I have had a similar problem with error code:

ERROR in ./src/app/my.service.ts   
Module not found: Error: Can't resolve '../../node_modules/@types/selenium-webdriver/http' in '...\src\app

Problem was with Visual Studio Code's Autoimport plugin importing HttpClient class from

'../../node_modules/@types/selenium-webdriver/http'

instead of

'../../node_modules/@angular/common/http'

I found this question somehow helpful, but it did not give me a clear answer. I post what I found out so that another visitor will have it easier.


I had same issue when I was working with Angular and Laravel where I wanted to add HTTP module in app.module.ts and also in my.component.ts but it added to the selenium HTTP client.

So I changed from

import { HttpClient } from 'selenium-webdriver/http';

To

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

Tags:

Angular6