Cannot find module 'rxjs-compat/Observable'

前端 未结 12 1367
孤街浪徒
孤街浪徒 2020-12-08 06:54

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 ope

相关标签:
12条回答
  • 2020-12-08 07:01
    npm install --save rxjs-compat
    
    import { Observable } from 'rxjs'
    

    run server ng serve worked for Me

    0 讨论(0)
  • 2020-12-08 07:06

    As, Jandro Rojas, already said, installing rxjs-compat dependency it's only a temporary walkaround. In the future, you still need to fix that. The best solution is to use an Angular update guide https://update.angular.io/ because of some mistakes can be fixed automatically.

    From my experience with errors "Cannot find module 'rxjs-compat/Observable'", "Cannot find module 'rxjs-compat'" and etc.

    • You should fix all the imports. From:
    import { Observable } from 'rxjs/Observable'
    

    To:

    import { Observable } from 'rxjs'
    
    • If you use RxJS observables classes or etc, you need to update your code. Use this guide -> RxJS v5.x to v6 Update Guide

    • Check carefully your dependencies, it should be updated too to use the newest RxJs. In my case "ngx-bootstrap" was outdated.

    0 讨论(0)
  • 2020-12-08 07:08

    I am using Angular 10,this method works for me.

    npm install --save rxjs-compat
    

    you should import observable this way:-

    import { Observable } from 'rxjs/Observable';
    
    0 讨论(0)
  • 2020-12-08 07:13
    npm install --save rxjs-compat
    

    and run the server again with ng serve

    This works for me.

    0 讨论(0)
  • 2020-12-08 07:15
    • ] node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'

    I have got same above error, to resolve the issue enter this command in you CLI:

    • npm install --save rxjs-compat

    Then after import: import { Observable } from 'rxjs';

    0 讨论(0)
  • 2020-12-08 07:16

    Those who have this error while creating a salesforce project in VSCode, should ensure that the command - npm install rxjs@6.3.2 --save && npm install rxjs-compat@6.3.2 --save

    are installed in - C:\Program Files\Salesforce CLI\client\node_modules directory

    0 讨论(0)
提交回复
热议问题