问题
I am trying to upgrade a basic angular skeleton app from angular 5 to angular 6 and here's the issue I am coming across when trying to run the app :
ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"C:/newAdmin/testing-front-end/admin-fe/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig'.
Here is my package.json :
{
"name": "admin-fe",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/core": "^7.3.0",
"@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",
"@ngrx/store": "^7.2.0",
"angular-oauth2-oidc": "^5.0.2",
"core-js": "^2.5.4",
"moment": "^2.24.0",
"rxjs": "6.3.3",
"rxjs-compat": "^6.4.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.7.0",
"@angular/cli": "~6.1.3",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "^2.9.1"
}
}
I do not get this error when using typescript 3.3.1 but I cannot use that since the compiler will only allow me till typescript < v2.10.0
What steps can I take here ?
EDIT :
I aligned both the rxjs and rxjs-compat versions to be 6.3.3 but now I am getting the following error:
ERROR in node_modules/@ngrx/store/src/store.d.ts(30,31): error TS2304: Cannot find name 'Extract'.
回答1:
I had same issue, I had to downgrade rxjs-compat(6.3.3) to align it with rxjs(6.3.3),
In your package.json it should be like:
"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",
If you are using rxjs 6.4.0, you don't need to use rxjs-compat, which provides a compatibility layer between rxjs v6 and v5.
So I think you can directly use import { shareReplay } from 'rxjs/operators';
More information on the operators here: https://www.learnrxjs.io/
回答2:
I had the same issue for the project where versions of rxjs and rxjs-compat were different in package.json file as rxjs="6.3.3" and rxjs-compat="6.4.0" so I just downgraded the rxjs-compat version by following command:
npm install rxjs-compat@6.3.3 --s
it worked for me.
回答3:
I faced identical issue with "rxjs": "6.3.3","rxjs-compat": "6.4.0"
and despite moving to version ^6.3.3
the error remained. Just a small addition. If you have ^
in your rxjs-compat
it may cause problem. Without the caret, i.e. rxjs-compat": "6.3.3"
it worked for me. Refer https://github.com/ReactiveX/rxjs/issues/4512. Thanks
回答4:
I faced the similar issue. But, it is solved when I used below versions of rxjs and rxjs-compat in the package.json. --->"rxjs": "6.3.3", --->"rxjs-compat": "6.3.3"
回答5:
In package.json file edit replace "rxjs-compat": "^6.4.0" => "rxjs-compat": "^6.3.3" and run command
npm install
回答6:
I was working with Angular 6 and the issue got resolved by removing
import 'rxjs/Rx';
from my code.
回答7:
npm install rxjs-compat@6.3.3 --s
above command has fixed the my issue
来源:https://stackoverflow.com/questions/54493256/error-in-node-modules-rxjs-compat-operator-sharereplay-d-ts2-10-error-ts2305