Angular 6: Module not found error regarding RxJs

Comment line : import 'rxjs/add/operator/toPromise';


You are using HttpModule which is deprecated you should use HttpClientModule instead

it's recommended to use Observables over promises. By converting to a promise you will lose the ability to cancel a request and the ability to chain RxJS operators.
Before you can use the HttpClient, you need to import the Angular HttpClientModule into root Module.

    import { NgModule }         from '@angular/core';
    import { BrowserModule }    from '@angular/platform-browser';
    import { HttpClientModule } from '@angular/common/http';

    @NgModule({
      imports: [
        BrowserModule,
        HttpClientModule,
      ],
//.......

Modified Code:

import { HttpClient} from '@angular/http';
import {Observable} from 'rxjs';    

    export class WebService{
        constructor(private httpc:Http){}
        getMessages():Observable<any>{
            return this.httpc.get("http://localhost:2000/messages"); 
        }
    } 

Regarding the error you are getting

As of rxjs 5.5.0-beta.5+ the toPromise method is now a permanent method of Observable. You don't need to import it anymore Reference

Since You are working with RXJS 6+ I would Recommend you to go through the Changes

LIVE DEMO WITH HTTPCLIENT