2

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.

Vikas
  • 11,859
  • 7
  • 45
  • 69
Rupesh
  • 840
  • 1
  • 12
  • 26

5 Answers5

5

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';

miken32
  • 42,008
  • 16
  • 111
  • 154
Anand Raja
  • 2,676
  • 1
  • 30
  • 35
1

install the whole rxjs-compact package

npm install --save rxjs-compat

Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80
  • I am getting the given below output :- ` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + rxjs-compat@6.3.3 added 1 package and audited 38281 packages in 65.387s found 12 vulnerabilities (9 low, 3 high) run `npm audit fix` to fix them, or `npm audit` for details ` – Rupesh Oct 02 '18 at 17:54
1

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

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)

Bubu
  • 5
  • 2
0

Try the following import : import { Observable } from 'rxjs-compat/observable'; rxjs has known some updates with time, and some syntaxes have changed. And in many cases, we now use use 'rxjs-compat', instead of 'rxjs'.