By Anurag Ranjan

2018-06-13 12:31:47 8 Comments

I am using Angular 6 where I am getting two errors -

  1. ERROR in ./src/app/app/img/img.service.ts Module not found: Error: Can't resolve 'rxjs/add/operator/map' in '/Users/user/Projects/A4/imageSearch/src/app/app/img'

  2. ERROR in src/app/app/img/img.service.ts(21,9): error TS2339: Property 'map' does not exist on type 'Observable'.


@Nodirabegimxonoyim 2018-06-22 12:49:03

I faced similar problem with rxjs map operator. Currently I'm using Angular 6. To know which version you are using:

ng --version


ng -v

If you are also using angular 6, then please checkout

  1. Different internal structure that requires you to change your import statements
  2. pipe() as a method to chain your operators, the old way of chaining them will not work

Let's say you use map for http.get method:

import { map } from 'rxjs/operators';

private url = "some site...";
  constructor(private http: HttpClient) { }

  dailyForecast() {
    return this.http.get(this.url).pipe(map(result => result));

NOT: this.http.get(this.url).map(result => result);

@kronus 2018-07-07 13:20:55

Thank you so much for this explanation @nodirabegimxonoyim

@Nodirabegimxonoyim 2018-08-06 11:17:49

@kronus you are welcome. I am glad if it was helpful

@Ajinath S 2018-12-22 10:24:40

With rxjs 6, import path is changed. Please import operator like this

  1. import {Observable} from 'rxjs';
  2. import {map} from 'rxjs/operators';

Hope it will work.

@user3345521 2018-07-26 20:29:12

Run command in your package.

npm install --save rxjs-compat

And import below line in your file.

import 'rxjs-compat';

@Iancovici 2018-06-13 12:40:28

This is how we can import observable and map in rxjs 6

import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';

@Anurag Ranjan 2018-06-13 12:45:00

thanks . error is fixed now god bless you

Related Questions

Sponsored Content

22 Answered Questions

16 Answered Questions

14 Answered Questions

[SOLVED] Angular - "has no exported member 'Observable'"

7 Answered Questions

2 Answered Questions

error TS2339: Property 'do' does not exist on type 'Observable<HttpEvent<any>

1 Answered Questions

[SOLVED] Property 'catch' does not exist on type 'Observable<IEmployee[]>'

2 Answered Questions

2 Answered Questions

[SOLVED] Module not found: Error: Can't resolve 'rxjs/add/observable/throw'

  • 2018-06-04 11:31:42
  • Gautham Pughazhendhi
  • 8862 View
  • 3 Score
  • 2 Answer
  • Tags:   angular rxjs

16 Answered Questions

Sponsored Content