ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.65k stars 3k forks source link

rxjs requires rxjs-compat #3764

Closed Pu4 closed 6 years ago

Pu4 commented 6 years ago

Hi. I'm trying to upgrade my angular app to fresh version using steps from this article https://www.ngdevelop.tech/upgrade-angular-5-to-6/ Everything worked fine, after running rxjs-5-to-6-migrate command linter found and fixed some issues, ng serve worked as well. But after I removed rxjs-compat I got one error

ERROR in node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat'.

This is the only error in console, Rx.d.ts file contains single line of code

export * from 'rxjs-compat';

Removing and reinstalling all packages from node_modules also didn't worked. Am I doing something wrong?

Additional information: package.json

{
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor",
    "build-with-ngsw-fix": "ng build --prod && npm run ngsw-fix-windows",
    "ngsw-fix": "yes | cp -rf src/ngsw-worker.js dist/",
    "ngsw-fix-windows": "copy src\\ngsw-worker.js dist /y",
    "ngsw-config": "node_modules/.bin/ngsw-config dist src/ngsw-config.json",
    "ngsw-copy": "cp node_modules/@angular/service-worker/ngsw-worker.js dist/",
    "build-prod-ngsw": "ng build --prod && npm run ngsw-config && npm run ngsw-copy",
    "serve-prod-ngsw": "npm run build-prod-ngsw && http-server dist -p 8080"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/schematics": "0.0.40",
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.1",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/platform-server": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@angular/service-worker": "^6.0.3",
    "@types/jquery": "^3.3.2",
    "@types/underscore": "^1.8.8",
    "bootstrap": "3.3.7",
    "class-transformer": "^0.1.9",
    "core-js": "2.4.1",
    "font-awesome": "4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "3.1.1",
    "ngx-bootstrap": "^3.0.0",
    "ngx-color-picker": "4.5.0",
    "ngx-gallery": "^2.4.1",
    "primeng": "^6.0.0-alpha.1",
    "quill": "1.3.2",
    "rxjs": "^6.2.0",
    "rxjs-compat": "^6.2.0",
    "rxjs-tslint": "^0.1.4",
    "schematics": "^0.2.0",
    "screenfull": "3.0.2",
    "toastr": "2.1.2",
    "ts-helpers": "1.1.1",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.6.7",
    "@angular/cli": "^6.0.7",
    "@angular/compiler-cli": "^6.0.3",
    "@types/jasmine": "2.5.53",
    "@types/node": "8.0.7",
    "codelyzer": "^4.3.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.4.1",
    "karma-chrome-launcher": "2.0.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "0.2.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "protractor": "5.2.0",
    "ts-node": "2.0.0",
    "tslint": "^5.10.0",
    "typescript": "^2.7.2"
  }
}
pitAlex commented 6 years ago

rxjs-compat is required if you do any import like rxjs/something ex : import { Subject } from "rxjs/Subject". A way to find out if anything you import is done "the old way" is by checking the file of the module your are importing. For example in node_modules/rxjs/Subject.js you will find it wants rxjs-compat. But import { Subject } from "rxjs" has its origin in the new structure. I had same problems because I had import "rxjs/add/operator/..."; in some places, so thats also another reason.

arch-daemone commented 6 years ago

It almost sounds like somewhere in your own code, you're importing from 'rxjs/Rx'. If that's the case, simply find where that import is, and replace it with an import from the new improved index (e.g. import {Observable} from 'rxjs';).

The thing is, you've already been over your code with the linter. So it sounds more like you have a dependency on a library that is importing from 'rxjs/Rx'. If the import isn't in your code, it's in your node_modules. If that's the case, you'll need to re-introduce rxjs-compat for now, and petition the author of the library to update to RxJS 6.

Pu4 commented 6 years ago

@DaemonExMachina, thank you. I found single rxjs/Rx import in one of the files and removed it. That solved my issue.