I am receiving an error when trying to build my application using angular 6 and have no idea what to do.
Module rxjs not found see this
Module not found ..Cannot resolve module 'rxjs/operators/toPromise
what should i do ?
// the contact.service.ts
import { Injectable } from '@angular/core';
import { Contact } from './contact';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class ContactService {
private contactsUrl = '/api/contacts';
constructor (private http: Http) {}
.......
}
try to remove the import statement. It should work without that. Below code works.
new Observable().toPromise();
From rxjs 5.5, "toPromise: now exists as a permanent method on Observable"
From rxjs 6 onwards toPromise is not an operator, it is part of observable object, you should be able to access directly without any imports
来源:https://stackoverflow.com/questions/50896544/module-not-found-cannot-resolve-module-rxjs-operators-topromise-with-angular6