Cannot find module 'rxjs-compat/Observable'

前端 未结 12 1368
孤街浪徒
孤街浪徒 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条回答
  • npm i rxjs-compat
    

    It's working for me.

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

    Just open command prompt & add below command in to your root folder.

    npm i rxjs-compat
    

    Hope it's working ..

    0 讨论(0)
  • 2020-12-08 07:18
    import { Observable } from 'rxjs';
    

    this will be enough, there's no need for other imports

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

    None of these answers are correct. Installing rxjs-compat is just a workaround. All you have to do is correct the imports. Use:

    import { Observable } from 'rxjs';
    

    Instead of:

    import { Observable } from 'rxjs/Observable';
    

    This last import is supposed to go away when they finally decide to kill rxjs-compat (hopefully very soon)... so heads up! you need to update your code!!

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

    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

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

    Both the rxjs and rxjs-compat of the version 6.3.2 worked for me.

    npm install rxjs@6.3.2 --save  &&  npm install rxjs-compat@6.3.2 --save
    
    0 讨论(0)
提交回复
热议问题