Angular - “has no exported member 'Observable'”

后端 未结 14 1882
陌清茗
陌清茗 2020-12-12 11:16

Typescript code:

import { Injectable } from \'@angular/core\';
import { Observable } from \'rxjs/Observable\';
import { of         


        
相关标签:
14条回答
  • 2020-12-12 11:41

    Update angular-in-memory-web-api version. The default angular-in-memory-web-api version installed during the tutorial angular-tour-of-heroes was 0.4. It worked like a charm in my case. (Using Angular 7 with RxJS 6)

    npm i angular-in-memory-web-api@0.8.0
    
    0 讨论(0)
  • 2020-12-12 11:42

    This might be helpful in Angular 6 for more info refer this Document

    1. rxjs: Creation methods, types, schedulers and utilities
    import { Observable, Subject, asapScheduler, pipe, of, from, interval, merge, fromEvent } from 'rxjs';
    1. rxjs/operators: All pipeable operators:
    import { map, filter, scan } from 'rxjs/operators';
    1. rxjs/webSocket: The web socket subject implementation
    import { webSocket } from 'rxjs/webSocket';
    1. rxjs/ajax: The Rx ajax implementation
    import { ajax } from 'rxjs/ajax';
    1. rxjs/testing: The testing utilities
    import { TestScheduler } from 'rxjs/testing';
    0 讨论(0)
  • 2020-12-12 11:43

    In my case this error was happening because I had an old version of ng cli in my computer.

    The problem was solved after running:

    ng update

    ng update @angular/cli

    0 讨论(0)
  • 2020-12-12 11:44

    You are using RxJS 6. Just replace

    import { Observable } from 'rxjs/Observable';
    import { of } from 'rxjs/observable/of';
    

    by

    import { Observable, of } from 'rxjs';
    
    0 讨论(0)
  • 2020-12-12 11:46

    I had a similar issue. Back-revving RXJS from 6.x to the latest 5.x release fixed it for Angular 5.2.x.

    Open package.json.

    Change "rxjs": "^6.0.0", to "rxjs": "^5.5.10",

    run npm update

    0 讨论(0)
  • 2020-12-12 11:48

    Apparently (as you point in the error log), after updating to Angular 6.0.0 rxjs-compat is missing.

    Run npm install rxjs-compat --save to install. Should fix it.

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