Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'rxjs-compat/Observable'

Tags:

angular

rxjs

I am currently upgrading angular 4 to angular 6 code. I have installed "rxjs": "^6.3.2" and un-installed rxjs-compact as I have migrated the code to use the new rxjs operators. I am still getting the following errors. Dont know the reason why

ERROR in [at-loader] ./node_modules/rxjs/BehaviorSubject.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/BehaviorSubject'.  ERROR in [at-loader] ./node_modules/rxjs/Observable.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/Observable'.  ERROR in [at-loader] ./node_modules/rxjs/Observer.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/Observer'.  ERROR in [at-loader] ./node_modules/rxjs/Operator.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/Operator'.  ERROR in [at-loader] ./node_modules/rxjs/Subject.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/Subject'.  ERROR in [at-loader] ./node_modules/rxjs/Subscription.d.ts:1:15     TS2307: Cannot find module 'rxjs-compat/Subscription'. 
like image 524
Tom Avatar asked Sep 18 '18 14:09

Tom


People also ask

Can not find module RxJS compat Observable?

To solve the error "Cannot find module 'rxjs-compat/Observable'", make sure to install the package by opening your terminal in your project's root directory and running the following command: npm i rxjs and restart your IDE and development server.

Does RxJS need compat?

RxJS compat is nothing but a backward-compatibility layer that eases the update/migration process from RxJS 5 to RxJS 6. You should not rely on RxJS compat for any long term development, but instead, slowly upgrade your codebase which utilises any RxJS operators.

What is of operator in RxJS?

The of Operator is a creation Operator. Creation Operators are functions that create an Observable stream from a source. The of Operator will create an Observable that emits a variable amount of values in sequence, followed by a Completion notification.

What is subject in RxJS?

A subject in RxJS is a special hybrid that can act as both an observable and an observer at the same time. This way, data can be pushed into a subject, and the subject's subscribers will, in turn, receive that pushed data.


1 Answers

This will solve the issue:

npm install --save rxjs-compat  

See this GitHub issue

Edit : as per 10th October 2019 ,you can use below syntax as the earlier or the above one was a workaround.

import { Observable } from 'rxjs/Observable'; 

Reference doc: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#dropping-the-compatibility-layer

like image 121
Hameed Syed Avatar answered Sep 28 '22 05:09

Hameed Syed