Angular4应用程序中的RXJS突然出现问题。"找不到操作员.js"



我的 Angular4 应用程序突然出现问题,出现以下错误消息:

GET http://degould-login.dev/node_modules/rxjs/operators.js 404 (Not Found)

我不确定为什么它突然出现,并且我在软件包或核心架构中没有更改可能导致此问题的任何内容。

我可以看到 npm:rxjs 文件夹中不存在"运算符"js"文件,但我不知道是什么在请求它。

我的系统.JS文件

 /**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',
            // angular bundles
            '@angular/animations': 'node_modules/@angular/animations/bundles/animations.umd.min.js',
            '@angular/animations/browser':'node_modules/@angular/animations/bundles/animations-browser.umd.js',
            '@angular/platform-browser/animations': 'node_modules/@angular/platform-browser/bundles/platform-browser-animations.umd.js',
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs'                       : 'npm:rxjs',
            '@ngrx'                      : 'node_modules/@ngrx',
            'angular2-jwt'               : 'node_modules/angular2-jwt',
            'd3'                         : 'npm:d3',
            'ng2-charts'                 : 'npm:ng2-charts',
            'chart.js'                   : 'npm:chart.js',
            '@agm/core'                  : 'npm:@agm'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            'rxjs': {
                defaultExtension: 'js'
            },
            '@ngrx/store': {
                main: 'bundles/store.umd.js',
                format: 'cjs'
            },
            '@ngrx/core': {
                main: 'bundles/core.umd.js',
                format: 'cjs'
            },
            '@ngrx/store-devtools': {
                main: 'bundles/store-devtools.umd.js',
                format: 'cjs'
            },
            'angular2-jwt': {
                main: 'angular2-jwt.js',
                format: 'js'
            },
            'd3': {
                main: 'build/d3.js',
                defaultExtension: 'js'
            },
            'ng2-charts': {
                main: 'bundles/ng2-charts.umd.js',
                defaultExtension: 'js'
            },
            'chart.js': {
                main: 'dist/Chart.bundle.js',
                defaultExtension: 'js'
            },
            '@agm/core': {
                main: 'core/core.umd.js',
                defaultExtension: 'js'
            }
        }
    });
})(this);

和我的包.json

{
  "name": "degould-dashboard-frontend",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently "npm run tsc:w" "npm run build-css-watch"",
    "build": "tsc",
    "tsc:w": "tsc -w",
    "build-css": "node-sass --include-path scss assets/css -o app/assets/css",
    "build-css-watch": "node-sass --include-path scss assets/css -wo app/assets/css",
    "test": "concurrently "tsc -w" "karma start karma.conf.js"",
    "testnotsc": "karma start karma.conf.js"
  },
  "license": "ISC",
  "dependencies": {
    "@agm/core": "^1.0.0-beta.1",
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/platform-server": "4.0.0",
    "@angular/router": "^4.2.4",
    "@angularclass/conventions-loader": "^1.0.2",
    "@angularclass/hmr": "~1.2.2",
    "@angularclass/hmr-loader": "~3.0.2",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.1",
    "@ngrx/store-devtools": "^3.2.4",
    "@types/chart.js": "^2.6.1",
    "angular-2-local-storage": "^1.0.1",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "^3.3.7",
    "chart.js": "^2.6.0",
    "core-js": "^2.4.1",
    "d3": "^4.10.0",
    "heatmap.js": "^2.0.5",
    "jquery": "^3.2.1",
    "moment": "^2.18.1",
    "ng2-charts": "^1.6.0",
    "redux": "^3.6.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.5.2",
    "sass": "^0.5.0",
    "systemjs": "0.19.39",
    "tether": "^1.4.0",
    "toastr-ng2": "^4.1.1",
    "weather-icons": "^1.3.2",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/compiler-cli": "2.4.6",
    "@types/d3": "^4.10.0",
    "@types/jasmine": "^2.5.36",
    "concurrently": "^2.2.0",
    "gulp": "^3.9.1",
    "gulp-coffee": "latest",
    "gulp-concat": "latest",
    "gulp-connect": "latest",
    "gulp-sass": "latest",
    "gulp-typescript": "^3.0.2",
    "gulp-uglify": "latest",
    "gulp-useref": "^3.1.2",
    "gulp-util": "latest",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^4.0.9",
    "typescript": "2.4.1",
    "typings": "^1.3.2"
  }
}

有谁知道为什么我会收到此错误?我已经重新安装了我的 npm 包,我也手动重新安装了 rxjs。

谢谢

我从package.json中看到你有角度/cli。你在使用它吗?

如果是这样,常见的帖子表明angular/cli不需要systemjs。你有什么特别的原因吗?

如果这最初是systemjs,现在是angular/cli,请参阅将项目从SystemJS移动到Angular CLI/Webpack

如果你想保留systemjs,直接解决问题,

我注意到GET http://degould-login.dev/node_modules/rxjs/operators.js - rxjs 包中没有operators.js,有一个运算符文件夹。
因此,也许这与具有流氓".js"的导入声明有关?

当我回答另一个问题(使用 Plunker & SystemJs)时,这个错误突然出现。

这是在该 Plunker 上工作的 systemjs.config.js rxjs 映射条目。请注意,顺序可能很重要。

// other libraries
'rxjs/operators':            'npm:rxjs@5.5.2/operators/index.js',
'rxjs':                      'npm:rxjs@5.5.2',

最新更新