VansFannel
VansFannel

Reputation: 45921

import {take} from 'rxjs/operators/take' but 'rxjs/operators/take' folder doesn't exist

I'm developing an Angular 2 application using the Angular template of Visual Studio. For the web service I'm using ASP.NET Core 2. This is the package.json file contents:

{
  "name": "AngularWebApplication",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "dependencies": {
    "@angular/animations": "5.1.0",
    "@angular/cdk": "5.0.1",
    "@angular/common": "5.1.0",
    "@angular/compiler": "5.1.0",
    "@angular/compiler-cli": "5.1.0",
    "@angular/core": "5.1.0",
    "@angular/forms": "5.1.0",
    "@angular/http": "5.1.0",
    "@angular/material": "5.0.1",
    "@angular/platform-browser": "5.1.0",
    "@angular/platform-browser-dynamic": "5.1.0",
    "@angular/platform-server": "5.1.0",
    "@angular/router": "5.1.0",
    "@ngtools/webpack": "1.9.0",
    "@types/webpack-env": "1.13.0",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "3.2.1",
    "bootstrap": "3.3.7",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.9",
    "expose-loader": "0.7.3",
    "extract-text-webpack-plugin": "2.1.2",
    "file-loader": "0.11.2",
    "html-loader": "0.4.5",
    "isomorphic-fetch": "2.2.1",
    "jquery": "3.2.1",
    "json-loader": "0.5.4",
    "mdn-polyfills": "^5.2.0",
    "preboot": "4.5.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.5.5",
    "style-loader": "0.18.2",
    "to-string-loader": "1.1.5",
    "typescript": "2.4.2",
    "url-loader": "0.5.9",
    "webpack": "2.5.1",
    "webpack-hot-middleware": "2.18.2",
    "webpack-merge": "4.1.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@types/chai": "4.0.1",
    "@types/jasmine": "2.5.53",
    "chai": "4.0.2",
    "jasmine-core": "2.6.4",
    "karma": "1.7.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-webpack": "2.0.3"
  }
}

I have added @angular/material and then I need to update all @angular packages to version 5.1.0 and some of them to version 5.0.1. I have also update rxjs to version 5.5.5.

When I start the app I get the error:

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "rxjs/operators/take"

But I have found the following files in folder \node_modules\rxjs\operators\:

The problem is that there are several files in node_modules that I HAVEN'T MODIFIED with the following import:

import { take } from 'rxjs/operators/take'

I don't think I have to modify those files in node_modules folder to remove the take from the path (from 'rxjs/operators').

I have also run npm install -g @angular/cli without successful.

How can I solve this problem?

Upvotes: 2

Views: 4657

Answers (3)

Kurtis Jungersen
Kurtis Jungersen

Reputation: 2554

Per @Kirk-Larkin's answer on another SO post,:

Once you've installed the updated version, you'll need to get webpack to rebuild in the correct order. You might be able to get that to happen with a solution-level rebuild of the project(s), but if not, you can run the following to force webpack to build correctly:

webpack --config webpack.config.vendor.js

webpack

This, coupled with upgrading rxjs to v5.5.0, resolved the issue for me.

Upvotes: 0

praveen seela
praveen seela

Reputation: 528

for me it was due to mismatch in angular versions. run

sudo npm install -g @angular/cli

and build, it worked for me.

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222582

You need to use it as import { take } from 'rxjs/operators' inside the service/component

import { take } from 'rxjs/operators';

Upvotes: 0

Related Questions