Nabeel Hassan
Nabeel Hassan

Reputation: 492

Module not found: Error: Resolving to directories is not possible with the exports field (request was ./)

I upgraded angular from v11 to v12. I am getting this error and I dont know why. there are no changes in build configuration or tsconfig.

Upvotes: 20

Views: 10433

Answers (3)

Rahul Thakur
Rahul Thakur

Reputation: 166

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

just remove / from last of your import as Thomas Renger mentioned above.

like this

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

Upvotes: 12

Hamza Moustadraf
Hamza Moustadraf

Reputation: 81

Check your imports, you may find a path that ends with a '/', just remove it and it will work!

Upvotes: 8

Thomas Renger
Thomas Renger

Reputation: 1044

Simple example

Wrong import { BehaviorSubject } from 'rxjs/';

Correct import { BehaviorSubject } from 'rxjs';

I faced this issue during a migration. Search for something similar in your code to fix the issue. In my case the component causing the issue was mentioned in the error message.

Upvotes: 52

Related Questions