Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Error: Can't resolve 'rxjs/add/operator/catch' in 'F:\Angular\HttpServices\http-services\src\app'

Here is my code.

import { injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/catch';

@Injectable({
    providedIn: 'root'
})
export class PostsService {
    private url = 'https://jsonplaceholder.typicode.com/posts';
    constructor(private http : Http ) { }
    getPosts {
        return this.http.get(this.url);
    } 

    deletePost(id) {
        return this.http.get(this.url + '/' + id);
    }
}

I am doing this code on my PC it's working but not working on a laptop. It seems funny but this is true.
This is the structure of my project

like image 894
Ayjaz Sayed Avatar asked May 11 '18 11:05

Ayjaz Sayed


People also ask

Can't resolve RXJS operators angular 13?

To solve the error "Module not found: Error: Can't resolve 'rxjs'", make sure to install the rxjs package by opening your terminal in your project's root directory and running the command npm install rxjs and restart your development server.

What is RXJS compat for?

The rxjs-compat package was created so that developers could upgrade to RxJS version 6 without having to modify code. It re-implements the prototype-patching operators and makes available all of the RxJS-version-5 export locations.


1 Answers

New version of rxjs no longer supports single imports, instead try:

import { catchError } from 'rxjs/operators';
like image 57
Ivo Bogoevski Avatar answered Sep 20 '22 11:09

Ivo Bogoevski