2
votes

Here is the error :-

ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'. src/app/services/data.service.ts(44,10): error TS2305: Module '"C:/Users/Rupesh/Desktop/Projects/angulartest/node_modules/rxjs/Observable"' has no exported member 'Observable'.

I have tried npm install rxjs-compat/Observable but still getting error. Help to fix this.

4
Look into your package.json and post your RxJs Version?Vikas
"rxjs": "^6.3.3", "rxjs-compat": "^6.3.3",Rupesh

4 Answers

4
votes

You've to fix your Rxjs imports. There are some changes in the use of rxjs from v6 onwards. so, Kindly import the observable as below

import { Observable } from 'rxjs';

instaed of import { Observable } from 'rxjs/Observable';

Please check this

1
votes

install the whole rxjs-compact package

npm install --save rxjs-compat

1
votes

This is an old method.

import { Observable } from 'rxjs/Observable';

In angular 10 i have fixed this problem by using this method.

import { Observable } from 'rxjs';
0
votes

I have the same issue when I import Observable.

import { Observable } from 'rxjs/Observable';

until now, the only solution that i see is

import { Observable } from 'rxjs';

But in another question from Stack, i read that way will increase the page load (Best way to import Observable from rxjs)