RxJS version:
^6.1.0
Code to reproduce:
const Rx = require('rxjs/Rx');
Expected behavior:
It should work, right?
Actual behavior:
Mon May 14 2018 22:04:32 GMT+0000
Error: Cannot find module 'rxjs-compat'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/xemasiv/pac-1234/node_modules/rxjs/Rx.js:6:10)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
Additional information:
It's like #3629 but this time w/o tslint or any IDE involved, just bare ubuntu 17 w/ node 9.8.0
Doing yarn add rxjs-compat made it ran for me.
It seems like as stated in #3629, the rxjs-compat package is required for 6.0.0
Related to #3684, #3710
Keeping this open for now for easier discovery for lads from RxJS 5 docs.
I really think the v6 branch should've been kept at rxjs@next or similar until the v5 & v6 docs were updated. Just a funny mistake anyways, nothing serious.
Does that error happen for an empty app?
In my case I get the same error, but I am migrating from v5, and then the migration guide describes the steps for migrating using this rxjs-compat package (I haven't tried those steps yet, just found it). https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md
I think this is expected behaviour. The rxjs-compat package is only for compatibility reasons and to make upgrading to RxJS 6 easier but you're not supposed to be using it in the future (so I'd better avoid it completely).
This is the file you're importing when using 'rxjs/Rx' https://github.com/ReactiveX/rxjs/blob/master/legacy-reexport/Rx.ts and as you can see it just reexports everything from rxjs-compat.
So in fact the problem is that you shouldn't be importing from 'rxjs/Rx' at all and then you won't need rxjs-compat either.
Btw, information at http://reactivex.io/rxjs/manual/installation.html is outdated and seems to be for RxJS 5.4.
@martinsik So how should we import?
I'm also just trying to create Observable.fromEvent() but nothing seems to work...
@martinsik So can you please help us where should we import from then
import Rx from 'rxjs/Rx';
const { interval, fromPromise } = Rx.Observable;
I am using this and its throwing same error
@achyutjhunjhunwala @itaied246 It's all described here https://github.com/ReactiveX/rxjs#installation-and-usage
The documentation at http://reactivex.io/rxjs still mentions all of the old import paths and none of the new ones. Could it be that these documentation pages haven't been updated for v6 at all?
Yes it seems as the docs aren't up to date.
I managed to make it work this way:
import {fromEvent} from "rxjs";
what's the correct way to import fromPromise? i'm only able to do this:
import {fromPromise} from 'rxjs/internal-compatibility'
I suspect you use the from creation function mentioned in the migration guide that I linked above.
import { from } from 'rxjs';
const observable = from(new Promise((resolve => {
resolve('done');
})));
Or simply use the v5 branch of rxjs until the docs have been updated for v6.
Related to #3684, #3710
Keeping this open for now for easier discovery for lads from RxJS 5 docs.
I really think the v6 branch should've been kept at rxjs@next or similar until the v5 & v6 docs were updated. Just a funny mistake anyways, nothing serious.
Okay, so for now, I have http://reactivex.io/rxjs redirecting to the newer docs (with an HTML redirect unfortunately, until we have the new domain setup)
Hopefully that will end the confusion. Sorry, everyone, it's a work in progress.
Since i commented my concern here, i am posting what i did to solve my issue. In case some one arrives at this post, will know faster the solution -
Package.json - "rxjs": "^5.5.10",
Code -
import { Observable } from 'rxjs/Rx';
const { interval, fromPromise } = Observable;
Most helpful comment
Okay, so for now, I have http://reactivex.io/rxjs redirecting to the newer docs (with an HTML redirect unfortunately, until we have the new domain setup)
Hopefully that will end the confusion. Sorry, everyone, it's a work in progress.