angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
95.92k stars 25.35k forks source link

Can't resolve 'rxjs' #32132

Closed christophstockinger closed 5 years ago

christophstockinger commented 5 years ago

I run the build command and get the following error.

ERROR in ../node_modules/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/Observable' in '/Users/cstockinger/Documents/projects/easy2parts/easy2parts/src/E2P.Web/node_modules/@angular/core/@angular'
ERROR in ../node_modules/@angular/http/@angular/http.es5.js
Module not found: Error: Can't resolve 'rxjs/Observable' in '/Users/cstockinger/Documents/projects/easy2parts/easy2parts/src/E2P.Web/node_modules/@angular/http/@angular'
ERROR in ../node_modules/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/Subject' in '/Users/cstockinger/Documents/projects/easy2parts/easy2parts/src/E2P.Web/node_modules/@angular/core/@angular'
ERROR in ../node_modules/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/observable/merge' in '/Users/cstockinger/Documents/projects/easy2parts/easy2parts/src/E2P.Web/node_modules/@angular/core/@angular'
ERROR in ../node_modules/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/operator/share' in '/Users/cstockinger/Documents/projects/easy2parts/easy2parts/src/E2P.Web/node_modules/@angular/core/@angular'

I tried to find out the error, but unfortunately I can't reproduce it. It seems to me that there are wrong dependencies installed in Angular!

My Package.json-Dependencies:

{
"dependencies": {
    "@angular-redux/store": "^10.0.0",
    "@angular/animations": "~8.2.2",
    "@angular/cdk": "^8.1.2",
    "@angular/common": "~8.2.2",
    "@angular/compiler": "~8.2.2",
    "@angular/core": "~8.2.2",
    "@angular/forms": "~8.2.2",
    "@angular/material": "^8.1.2",
    "@angular/platform-browser": "~8.2.2",
    "@angular/platform-browser-dynamic": "~8.2.2",
    "@angular/router": "~8.2.2",
    "@microsoft/applicationinsights-web": "^2.0.0",
    "@ngrx/router-store": "8.2.0",
    "@ngrx/store": "8.2.0",
    "@ngrx/store-devtools": "8.2.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "core-js": "^3.2.1",
    "hammerjs": "^2.0.8",
    "jsrsasign": "^8.0.12",
    "lodash": "^4.17.15",
    "lory.js": "^2.5.3",
    "moment": "^2.24.0",
    "ngx-file-drop": "^8.0.7",
    "ngx-mat-daterange-picker": "^1.1.4",
    "objectFitPolyfill": "^2.3.0",
    "redux": "4.0.1",
    "redux-seamless-immutable": "0.4.0",
    "rxjs": "^6.4.0",
    "rxjs-compat": "6.3.3",
    "tslib": "^1.10.0",
    "universal-cookie": "^4.0.2",
    "zone.js": "~0.10.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.1",
    "@angular/cli": "~8.2.1",
    "@angular/compiler-cli": "~8.2.2",
    "@angular/language-service": "~8.2.2",
    "@types/node": "~12.7.1",
    "@types/jasmine": "~3.4.0",
    "@types/jasminewd2": "~2.0.6",
    "codelyzer": "~5.1.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.2.0",
    "karma-chrome-launcher": "~3.0.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.2",
    "redux-devtools-extension": "^2.13.8",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.5.3"
  }
}
santoshyadavdev commented 5 years ago

Hey @christophstockinger ,

Any stackblitz link you can provide to reproduce, also why so you have rxjs-compat still as dependency, it is required only during upgrade if you followed the migration doc, you can remove it once updated

sarunint commented 5 years ago

rxjs/Observable does not exists since RxJS v6. Please use the correct import endpoint.

christophstockinger commented 5 years ago

@sarunint Did you read the error message correctly? The import is in the core package of Angular!

christophstockinger commented 5 years ago

@santoshyadav198613 After I deleted rxjs-compat, the following errors occur. Therefore I think that I have to install it

1 export * from 'rxjs-compat/BehaviorSubject';
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/rxjs/Observable.d.ts:1:15 - error TS2307: Cannot find module 'rxjs-compat/Observable'.

1 export * from 'rxjs-compat/Observable';
                ~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/rxjs/Observer.d.ts:1:15 - error TS2307: Cannot find module 'rxjs-compat/Observer'.

1 export * from 'rxjs-compat/Observer';
                ~~~~~~~~~~~~~~~~~~~~~~
../node_modules/rxjs/Subscription.d.ts:1:15 - error TS2307: Cannot find module 'rxjs-compat/Subscription'.

1 export * from 'rxjs-compat/Subscription';
                ~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/rxjs/observable/of.d.ts:1:15 - error TS2307: Cannot find module 'rxjs-compat/observable/of'.

1 export * from 'rxjs-compat/observable/of';
santoshyadavdev commented 5 years ago

Looks like migration issue, as you don't have any reproduction, can you help me from which version you migrated from. Also check https://update.angular.io/ as you should remove rxjs-compat post migration.

maruthimohan commented 5 years ago

Hey @christophstockinger, were you able to resolve it? I am also getting the same issue. I have not migrated from any previous version. My project is new in Angular 8.

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.