XHR错误(404)加载https://unpkg.com/rxjs@5.4.3/operators/index.js/first.js

时间:2017-11-22 04:09:07

标签: angular rxjs material-design zone.js

我正在尝试在angular2中使用google材料输入控件但我在浏览器控制台中一直收到以下错误。

console error

我已经检查了我的'node_modules'文件夹,我看到它确实包含'rxjs'文件夹,但是只有'operator'文件夹而不是'运营商'文件夹,所以我可以理解它无法找到index.js或者首先。 JS。 从错误,看起来好像这个不可用的文件夹的引用似乎在zone.js内,但我找不到它。我也尝试使用最新的'rxjs'版本,即5.5.2没有运气。

你能看到其他任何错误吗?

提前致谢。

我从https://material.angular.io/

获得了以下一些代码

package.json

{
        "name": "aspnet",
        "version": "0.0.0",
        "scripts": {
            "postinstall": "typings install",
            "typings": "typings"
        },
        "license": "ISC",
        "devDependencies": {
            "typings": "0.8.1"
        },
        "dependencies": {
            "@angular/cdk": "^5.0.0-rc.1",
            "@angular/common": "^5.0.2",
            "@angular/compiler": "^5.0.2",
            "@angular/core": "^5.0.2",
            "@angular/forms": "^5.0.2",
            "@angular/http": "^2.0.0-rc.1",
            "@angular/material": "^5.0.0-rc.1",
            "@angular/platform-browser": "^5.0.2",
            "@angular/platform-browser-dynamic": "^5.0.2",
            "@angular/router": "2.0.0-rc.1",
            "@angular/router-deprecated": "2.0.0-rc.1",
            "@angular/upgrade": "2.0.0-rc.1",
            "angular2-in-memory-web-api": "0.0.9",
            "core-js": "^2.4.0",
            "reflect-metadata": "^0.1.3",
            "rxjs": "^5.4.3",
            "systemjs": "^0.19.27",
            "zone.js": "^0.8.18"
        }
    }

system.config.js

(function (global) {
    System.config({
        transpiler: 'ts',
        typescriptOptions: {
            "target": "es5",
            "module": "commonjs",
            "moduleResolution": "node",
            "sourceMap": true,
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "lib": ["es2015", "dom"],
            "noImplicitAny": true,
            "suppressImplicitAnyIndexErrors": true
        },
        meta: {
            'typescript': {
                "exports": "ts"
            }
        },
        paths: {
            // paths serve as alias
            'npm:': 'https://unpkg.com/'
        },
        // map tells the System loader where to look for things
        map: {
            'app': 'app',

            // angular bundles
            '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
            '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/common/http': 'npm:@angular/common/bundles/common-http.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/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.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/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
            '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
            '@angular/material/core': 'npm:@angular/material/bundles/material-core.umd.js',
            '@angular/material/input': 'npm:@angular/material/bundles/material-input.umd.js',
            '@angular/material/form-field': 'npm:@angular/material/bundles/material-form-field.umd.js',
            '@angular/cdk/platform': 'npm:@angular/cdk/bundles/cdk-platform.umd.js',
            '@angular/cdk/coercion': 'npm:@angular/cdk/bundles/cdk-coercion.umd.js',
            '@angular/cdk/bidi': 'npm:@angular/cdk/bundles/cdk-bidi.umd.js',
            '@angular/cdk/keycodes': 'npm:@angular/cdk/bundles/cdk-keycodes.umd.js',

            // other libraries
            'rxjs': 'npm:rxjs@5.4.3',
            'rxjs/operators': 'npm:rxjs@5.4.3/operators/index.js',
            'tslib': 'npm:tslib/tslib.js',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api@0.4/bundles/in-memory-web-api.umd.js',
            'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
            'typescript': 'npm:typescript@2.4.2/lib/typescript.js',

        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.ts',
                defaultExtension: 'ts',
                meta: {
                    './*.ts': {
                        loader: 'systemjs-angular-loader.js'
                    }
                }
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });

})(this);

test.ts

 import { Component } from '@angular/core';


    @Component({
        selector: 'testSelector',
        template: `
 <form class="example-form">
  <mat-form-field class="example-full-width">
    <input matInput placeholder="test" value="test">
  </mat-form-field>
</form>`


    })
    export class testComponent { }

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { testComponent} from './test';
import { MatInputModule } from '@angular/material/input';
@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        MatInputModule
    ],
    declarations: [
        testComponent
    ],
    providers: [
    ],
    bootstrap: [testComponent]
})
export class AppModule { }

HTML:

 <testSelector></testSelector>

1 个答案:

答案 0 :(得分:0)

我设法找到了解决这个问题的方法。问题出在system.config中的以下行:

'rxjs/operators': 'npm:rxjs@5.4.3/operators/index.js',

我对此进行了评论并开始工作。我注意到某些版本的rxjs支持'运营商'而不是我正在使用的版本。

此外,我发现本文有助于使用angular2:https://coursetro.com/posts/code/113/How-to-Build-an-Angular-5-Material-App

设置Google素材