angular-cli: upgrading to rxjs to 6.0.0-beta.1 fails with Error: Can't resolve 'rxjs/operator/share'

Versions

Angular CLI: 1.7.3
Node: 9.9.0
OS: darwin x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

Repro steps

  • Step 1
ng new test
  • Step 2

According to RxJS Update Guide https://goo.gl/osWFzo
in package.json replace

    "rxjs": "^5.5.6"

with

    "rxjs": "^6.0.0-beta.1",
    "rxjs-compat": "^6.0.0-beta.1",
  • Step 3
ng serve

Observed behavior

 $ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-03-24T19:09:06.172Z
Hash: 5362f398b275ad9aa305
Time: 5380ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 17.9 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 549 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 41.5 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 7.87 MB [initial] [rendered]

ERROR in ./node_modules/@angular/core/esm5/core.js
Module not found: Error: Can't resolve 'rxjs/operator/share' in 'test/node_modules/@angular/core/esm5'

Desired behavior

App should start normally

Mention any other details that might be useful (optional)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

npm install rxjs@6 rxjs-compat@6 --save

firstly changed in package.json rxjs oldest versione rxjs “6.0.0-rc.0” and then run npm install rxjs-compat --save

@nhhockeyplayer see what the new import paths should be here.

@nhhockeyplayer

As @samherrmann pointed out, the import paths you specified are incorrect, ‘rxjs/Observable’ becomes just ‘rxjs’.

@rahulbhooteshwar

I would make sure your dependencies are cleanly upgraded, by this i mean delete your package-lock.json and your node_moduels directory and redo your npm install command, i’ve had issues in the past with packages not actually installing correctly because the package-lock.json file has an old version of packages in it.

for me this didn’t work yet, as I struggle with

Cannot read property 'host' of null
TypeError: Cannot read property 'host' of null
    at Architect._loadJsonFile (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular-devkit\architect\src\architect.js:200:32)
    at Architect.loadArchitect (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular-devkit\architect\src\architect.js:68:45)
    at MergeMapSubscriber.workspaceLoader.loadWorkspace.pipe.operators_1.concatMap.workspace [as project] (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\models\architect-command.js:150:184)
    at MergeMapSubscriber._tryNext (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\operators\mergeMap.js:122:27)
    at MergeMapSubscriber._next (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\operators\mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\Subscriber.js:93:18)
    at DoSubscriber._next (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\operators\tap.js:88:30)
    at DoSubscriber.Subscriber.next (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\Subscriber.js:93:18)
    at MergeMapSubscriber.notifyNext (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\operators\mergeMap.js:145:30)
    at InnerSubscriber._next (C:\Users\WM3\Documents\GitHub\WMF3\node_modules\@angular\cli\node_modules\rxjs\InnerSubscriber.js:23:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wmf3@0.0.2 start: `ng serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wmf3@0.0.2 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


since 2 days now.


  "name": "wmf3",
  "version": "0.0.2",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "lint": "ng lint",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "build": "ng build",
    "start": "ng serve",
    "test": "ng test",
    "e2e": "ng e2e",
    "doc": "ng doc"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.0-rc.0",
    "@angular/cdk": "github:angular/cdk-builds",
    "@angular/common": "^6.0.0-rc.0",
    "@angular/compiler": "^6.0.0-rc.0",
    "@angular/core": "^6.0.0-rc.0",
    "@angular/forms": "^6.0.0-rc.0",
    "@angular/http": "^6.0.0-rc.0",
    "@angular/material": "github:angular/material2-builds",
    "@angular/platform-browser": "^6.0.0-rc.0",
    "@angular/platform-browser-dynamic": "^6.0.0-rc.0",
    "@angular/router": "^6.0.0-rc.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0-beta.2",
    "zone.js": "^0.8.20"
  },
  "devDependencies": {
    "@angular/cli": "next",
    "@angular/compiler-cli": "^6.0.0-rc.0",
    "@angular/language-service": "^6.0.0-rc.0",
    "@types/jasmine": "^2.8.6",
    "@types/jasminewd2": "^2.0.3",
    "@types/node": "^9.6.0",
    "autoprefixer": "^8.1.0",
    "circular-dependency-plugin": "^4.4.0",
    "codelyzer": "^4.2.1",
    "css-loader": "^0.28.11",
    "cssnano": "^3.10.0",
    "exports-loader": "^0.7.0",
    "file-loader": "^1.1.11",
    "html-webpack-plugin": "^3.1.0",
    "istanbul-instrumenter-loader": "^3.0.0",
    "jasmine-core": "~3.1.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.4.2",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "less-loader": "^4.1.0",
    "postcss-loader": "^2.1.3",
    "postcss-url": "^7.3.1",
    "protractor": "~5.3.0",
    "raw-loader": "^0.5.1",
    "rxjs-compat": "^6.0.0-beta.3",
    "sass-loader": "^6.0.7",
    "script-loader": "^0.7.2",
    "source-map-loader": "^0.2.3",
    "style-loader": "^0.20.3",
    "stylus-loader": "^3.0.2",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "^2.8.1",
    "url-loader": "^1.0.1",
    "webpack": "~4.3.0",
    "webpack-dev-server": "^3.1.1"
  },