0
votes

After installing npm install --save rxjs-compat ,

I got an error in Angular 6 application

Error:

Uncaught Error: Unexpected value 'Observable' imported by the module 'AppModule'. Please add a @NgModule annotation.
    at syntaxError (compiler.js:1021)

my app module --

import { Observable, Subject } from 'rxjs';
import { AuthService } from './_services/auth.service';

@NgModule({
   declarations: [
      AppComponent,
      ValueComponent,
      NavComponent
   ],
   imports: [
      BrowserModule,
      HttpClientModule,
      FormsModule,
      Observable,
      Subject
    ],

package.json--- "dependencies": { "@angular/animations": "^6.1.0", "@angular/common": "^6.1.0", "@angular/compiler": "^6.1.0", "@angular/core": "^6.1.0", "@angular/forms": "^6.1.0", "@angular/http": "^6.1.0", "@angular/platform-browser": "^6.1.0", "@angular/platform-browser-dynamic": "^6.1.0", "@angular/router": "^6.1.0", "bootstrap": "^4.1.3", "core-js": "^2.5.4", "font-awesome": "^4.7.0", "jquery": "^3.3.1", "rxjs": "^6.3.2", "rxjs-compat": "^6.3.2", "zone.js": "~0.8.26" },

1
Welcome to SO, can you show us your app.module.ts code please.Chris
you should not import Observable, Subject in modulesomurbek

1 Answers

0
votes

Like Omurbek Kadyrbekov mentioned in comment, you should not import rxjs into your modules.

In components, try exact import:

import { Observable } from 'rxjs/Observable';

instead of your

import { Observable, Subject } from 'rxjs';