Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RXJS own d.ts file error #3654

Closed
Son-Lam opened this issue May 6, 2018 · 60 comments
Closed

RXJS own d.ts file error #3654

Son-Lam opened this issue May 6, 2018 · 60 comments

Comments

@Son-Lam
Copy link

Son-Lam commented May 6, 2018

node_modules/rxjs/BehaviorSubject.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/BehaviorSubject'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
node_modules/rxjs/Observer.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observer'.
node_modules/rxjs/ReplaySubject.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/ReplaySubject'.
node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat'.
node_modules/rxjs/Subject.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subject'.
node_modules/rxjs/Subscriber.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscriber'.
node_modules/rxjs/Subscription.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscription'.
node_modules/rxjs/observable/forkJoin.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/observable/forkJoin'.
node_modules/rxjs/observable/from.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/observable/from'.
node_modules/rxjs/operators/map.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/operators/map'.
node_modules/rxjs/operators/startWith.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/operators/startWith'.

RxJS version:

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

@cartant
Copy link
Collaborator

cartant commented May 6, 2018

With the issue including neither the version information nor the code that effects the errors, it's not possible to say precisely what the problem is. That's why the issue template should be filled out.

However, those sorts of errors will be effected if v5-style imports are used when rxjs v6 is installed without rxjs-compat also being installed. It's explained in the migration guide.

@vytautas-pranskunas-
Copy link

I am facing same issue. Installed rxjs 6 and in Observable.d.ts there is an import
export * from 'rxjs-compat/Observable';
which causes the error
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

so do i need to install rxjs-compat always?

@vytautas-pranskunas-
Copy link

btw when i try to run migration script:
Command failed: ..path\node_modules\rxjs-tslint\node_modules.bin\tslint -c ...path\node_modules\rxjs-tslint\rxjs-5-to-6-migrate.json -p [C:...pathg.../tsconfig.json] --fix

@sachinpachori
Copy link

I am facing same issue after angular 6 update.

@SnakeME
Copy link

SnakeME commented May 8, 2018

@vytautas-pranskunas- @sachinpachori The errors disappeared for me when I've updated the import paths according to the migration guide: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths

@bluefire2121
Copy link

rxjs-tslint isn't picking up the migration changes necessary in rxjs

@bluefire2121
Copy link

bluefire2121 commented May 8, 2018

and inside of Observable.d.ts, why do we need to export * from 'rxjs-compat/Observable if the goal is to relieve our reliance on rxjs-compat?

@rhythmnewt
Copy link

I have rxjs 6.1.0 installed and after running the migration tool and using the rxjs-tslint I get the same error. Obviously if I add back the rxjs-compat node module, this error disappears and everything compiles fine.

ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'
     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0
Node: 9.2.0
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/cdk                      6.0.1
@angular/material                 6.0.1
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

@maharjanraj
Copy link

I am also facing the same problem.

node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.

@sachinpachori
Copy link

@SnakeME In my case it didn't and I need to keep the rxjs-compat to get it working locally however now my build definition is failing and I am looking at it.

@mrcampbell
Copy link

In the meantime, a quick fix for me was to roll back to 5.x:

npm install --save rxjs@5.5.10

@Crash1988
Copy link

for me npm install rxjs@6 rxjs-compat@6 --save did the trick, i dont know if this might help someone else,
i found it here

@ninad-d
Copy link

ninad-d commented May 10, 2018

reinstalling rxjs and rxjs compat did the trick for me. "npm install --save rxjs@6 rxjs-compat@6".

@vytautas-pranskunas-
Copy link

vytautas-pranskunas- commented May 10, 2018

Problem is that rxjs-compat@6 will be depricated in v7. So question is if I want to remove rxjs-compat@6 how should i do this. To tell the truth i do not have it at the moment also so question is what should i do not depend on it - but not how to get rid of just that error.

If you want just to ged rid of error add to typescript config skipLibCheck: true.

@Son-Lam
Copy link
Author

Son-Lam commented May 10, 2018

I have cleaned the code and got it work. I avoid using rxjs-compat as well. Thanks.

@Son-Lam Son-Lam closed this as completed May 10, 2018
@vytautas-pranskunas-
Copy link

Have you released new version with cleaned code?

@HamzaNasim
Copy link

HamzaNasim commented May 10, 2018

@mrcampbell it's not possible to downgrade rxjs to 5.5.10 because this version is not supported by Angular v6 .

@sachinpachori
Copy link

how come these obvious issues not caught before releasing Angular6?

@rhythmnewt
Copy link

This shouldn't be closed until the fix is in.

@tydanielson
Copy link

This happens when you haven't updated other imports that require Subject etc. from the old location. Update the other imports in your other files and these will go away.

@jamesclark92
Copy link

@Son-Lam how did you exactly fix this though?

@SnakeME
Copy link

SnakeME commented May 14, 2018

@jamesclark92 Check your import paths https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths

When you have updated them the error should disappear.

@SnakeME
Copy link

SnakeME commented May 14, 2018

@jamesclark92 Yes I know, for me the errors disappeared when I've corrected the imports in my TypeScript files. It seems like rxjs is doing some kind of fallback or check when it detects that you are using an old import statement.

@rhythmnewt
Copy link

I stand corrected with the error I was getting, the culprit was a package dependency that was using rxjs/Observable import. As soon as I updated to a more recent version that supported rxjs 6, the error went away and I was able to drop the rxjs-compat package.

@voy22
Copy link

voy22 commented May 15, 2018

npm install --save rxjs@6 rxjs-compat@6

  • solution for me. Thank you!

@daditangs
Copy link

In order to minimize the impact of the upgrade, RxJS v6 releases with a sibling package, rxjs-compat, which provides a compatibility layer between the v6 and v5 APIs. Most developers with existing applications should upgrade by installing both rxjs and rxjs-compat at ^6.0.0:

npm install rxjs@6 rxjs-compat@6 --save

@tobyStaff
Copy link

@dimkanewtown thanks for your last comment, how exactly did you determine which dependency was the culprit in your app? I have many dependencies that could be involved - do you have a quick way to find the needle in the haystack?

@rhythmnewt
Copy link

@tobyStaff in my case I only had a few dependencies which I was able to check manually

@bibhas2
Copy link

bibhas2 commented May 23, 2018

In my case it turned out that the @angular/flex-layout package I was using depended on rxjs-compat. I upgraded to the latest version and the problem went away.

So in summary this is what I did:

  1. Install rxjs-compat. We will need this temporarily. Otherwise rxjs-5-to-6-migrate won't run as long as you have compilation errors.
  2. Install rxjs-tslint.
  3. Upgrade third party packages you may be using.
  4. Run rxjs-5-to-6-migrate to migrate your code to RxJs 6.
  5. Manually fix all import statements. For example Observable is now imported form rx module.
  6. Uninstall rxjs-compat. We should not need this any more.
  7. Do a build to make sure everything compiles just fine.

@pleerock
Copy link

rxjs-compat is already kinda minimal and there is no point in developing multiple other versions. Simply install rxjs-compat and use it.

@danmana
Copy link

danmana commented May 29, 2018

From my understanding, installing rxjs-compat removes all benefits you could gain from tree-shaking. It bundles the entire rxjs library, even if you use just some parts.

In my case, with rxjs-compat main.js is 691 KB, without it (and a patched library import) it's 671 KB.

I know this sounds like a small difference, but since tree-shake-ability is listed as reason number 2 (and 3) for the recent change in API, I'd like to be able to benefit from it.

If I find a way to achive this, I'll post it here, but I'm not going to invest a lot of time in searching for this, as it is a small difference at the moment.

@danmana
Copy link

danmana commented May 29, 2018

I've managed to get a smaller rxjs-compat working in an Angular project using paths in tsconfig to override the needed imports

@camden-kid
Copy link
Contributor

Running rxjs-5-to-6-migrate (as mentioned by @bibhas2) on my project (described here - https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md) fixed the problem for me.

@cm0s
Copy link

cm0s commented Jun 5, 2018

package zone.js is not rxjs 6 compatible. There is an open issue : angular/zone.js#1091. Next release will probably correct that.

@daditangs
Copy link

Hi,

I just reinstalled it:

$npm install rxjs@6 rxjs-compat@6 --save

and it worked on my end.

@phoude
Copy link

phoude commented Jun 6, 2018

I was having this error:
ERROR in node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat'.

I fixed it after finding the following import statement in app.module.ts.
import 'rxjs/Rx';

Upgrading 3rd party packages was part of the solution but search your code for "rxjs/" and you may find your issue like I did.

@sssalib42
Copy link

sssalib42 commented Jun 20, 2018

Update:
I confirm that I did find 'rxjs/Rx' imports that were not covered by the rxjs 6 linting tool.

Perhaps this needs to be addressed by the folks testing and developing the rxjs linting tool?!

Also, after updating a third party library which was still using old rxjs5 syntax, the list of errors related to its files disappeared.

Unfortunately, not all the libraries which we're using in our project has updated to rxjs 6 syntax, so I'm stuck with rxjs-compat until they are all up to date.

Thanks.

@rishidadheech
Copy link

this is because what version you are using of Angular CLI is V6 and what project you are using is of V5 or less than that.

@mohammad-tanzeel
Copy link

we need ti install rxjs and rxjs-compat packages to use the Observable.
I got fixed issue by using "npm install rxjs@6 rxjs-compat@6 --save".

@AndriiKost
Copy link

had the same issue when updated my project to angular 6. Got fixed by using "npm install rxjs@6 rxjs-compat@6 --save".

@Adan-Lopez
Copy link

@pleerock "import { Observable } from 'rxjs'; " worked for me thank you.

@Massay
Copy link

Massay commented Jul 21, 2018

npm install --save rxjs-compat@6 did the trick.

Thanks guys!

@babacardiop
Copy link

Still not working on my side!
Here is my lite-server output:

[1] 18.07.26 12:48:37 404 GET /node_modules/rxjs/
[1] 18.07.26 12:48:37 404 GET /node_modules/rxjs/operators.js

Can someone provide a full explanation ?

@tbadlov
Copy link

tbadlov commented Aug 1, 2018

Hello all, not sure why this issue is closed. Installing npm install --save rxjs-compat is a not a solution because our solution may not require this package. This either needs to be dependency of RxJs or corrected such that it is not affecting out code. Is there any update on this?

@sssalib42
Copy link

sssalib42 commented Aug 13, 2018

Summary:

Is this issue to be fixed by rxjs team?
No.

Why am I getting this error then?
Your own written code, and/or code in npm packages you installed in your project is still using old rxjs 5 code syntax.

What if I searched all my code and I don't find reference to old rxjs 5 syntax, but still getting this error?
One of your npm packages in the node_modules folder is still using the syntax. You can open the package.json file included in suspected packages node_modules folder and read their rxjs dependency version.

Will installing rxjs-compat fix this issue, as suggested by many comments here?
Yes, but this shouldn't be considered a final solution, as this compatibility package was designed to aid you upgrade slowly by allowing both rxjs 5 and 6 to run along side until you completely remove all old rxjs 5 code from your project. The compatibility package (rxjs-compat) increases the website JavaScript bundle size, and must be removed as a final step in your migration process.

How do I upgrade my code to rxjs 6 syntax appropriately?
In a nutshell, you will need to follow these two steps:
1-Run a migration tool (rxjs-5-to-6-migrate -p <config file>) created by the rxjs team that will parse your entire code and update your import statements and pipe structure for you. For this step it's possible you may need to do some googling to resolve a couple of manual handling of special cases, only if you get compilation errors, but there is good conversations on stack overflow to guide you through any potential errors.
2- You will need the rxjs compatibility package until you have completely removed all rxjs 5 code from your project then you should remove the compatibility package because otherwise it increases the bundle size of your website, which negatively affects the performance of your website.
Here are two good valuable resources:
https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md
https://auth0.com/blog/whats-new-in-rxjs-6/

Good Luck.

@atluriajith
Copy link

atluriajith commented Aug 14, 2018

yarn add rxjs@6.2.2 rxjs-compat@6.2.2 --S --E followed by 'yarn install' will fix.

@veerpratik
Copy link

reinstalling rxjs and rxjs compat did the trick for me. "npm install --save rxjs@6 rxjs-compat@6".

@bgies
Copy link

bgies commented Aug 28, 2018

For those that are struggling to get rid of the ERROR in node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat'. after you remove the compatibility layer....

All the people telling you to fix your paths are correct, but it would be better if they told you how to find them... I spent hours going through my code and couldn't find anything wrong:

What Worked: Go to node_module/rxjs/Rx.d.ts and "TEMPORARILY" comment out export * from 'rxjs-compat';
Now do an ionic build, and all the bad paths will be in the build errors. In my case it was an import 'rxjs/Rx'; statement.
When you get rid of the bad paths, change your node_module/rxjs/Rx.d.ts back to the original, and ionic build will now work.

@Yascin081
Copy link

Hi guys
in rxjs 5 always use import { Observable } from 'rxjs/Observable';
but in rxjs 6 you should use import { Observable } from 'rxjs';

I hope it is help

@Auxcon
Copy link

Auxcon commented Sep 3, 2018

this worked for me: #3654 (comment)

@shravanvis
Copy link

npm i rxjs-compat
this works for me.....

@policz
Copy link

policz commented Sep 6, 2018

I have the same issue with rxjs-compat.
currently i'm using Angular 6 .
my rxjs version 6.2.2 , yes after installing the rxjs-compat everything is working fine but is there any other solution without installing rxjs-compat

ERROR in node_modules/ngx-editor/app/ngx-editor/common/services/message.service. d.ts(1,10): error TS2305: Module '"C:/Users/frontend/node_modules/rx js/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs- compat/Observable'.

@sssalib42
Copy link

sssalib42 commented Sep 6, 2018

rxjs-compat (compatibility package) is to temporarily let you use old rxjs 5 syntax code along side rxjs 6.

You will need to remove it as a final step in your upgrade process.

Have you used https://update.angular.io/?
Particularly, the "After The Update" section, it includes detailed steps on how to upgrade from rxjs 5 to rxjs 6.

@sssalib42
Copy link

sssalib42 commented Sep 6, 2018

Guys, beware!

Zone.js library has NOT updated their code to RxJS 6, yet!!
angular/zone.js#1122

My team is waiting on their RxJS 6 update PR to be merged before we are able to get rid of the rxjs-compat (comparability) package.

This is an example of how relying on a major library can stop hundreds of projects from upgrading! smh

@charliearaya
Copy link

What solved it for me was removing this import from all places:
import 'rxjs/Rx';

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests