Angular2 RC7 Http模块加载错误

Angular2 RC7 Http module error loading

我有一个用 RC4 编写的 Angular2 测试应用程序,运行良好。我现在正尝试将其升级到 RC7,但收到以下错误消息

Error: SyntaxError: Unexpected token <
    Evaluating http://localhost:7864/traceur
    Error loading http://localhost:7864/traceur
    Error loading http://localhost:7864/libs/@angular/http/index.js as "@angular/http" from http://localhost:7864/app/recentActivity/recentActivity.module.js

我的 recentActivity.module 看起来像这样:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';

import { RecentActivityService } from './recentActivity.service';
import { RecentActivityComponent } from './recentActivity.component';

@NgModule({
    imports: [CommonModule, HttpModule],
    declarations: [RecentActivityComponent],
    exports: [RecentActivityComponent],
    providers: [RecentActivityService]
})
export class RecentActivityModule {
}

我想不通这是什么问题。如果我查看网络流量,我可以看到下载状态为 200 的 @angular/http/index.js 并且下载的文件是预期的结果。所以我不知道为什么它说加载它时出错。我还需要看哪里。

systemjs.config低于

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function () {
    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'libs/@angular',
        'angular2-in-memory-web-api': 'libs/angular2-in-memory-web-api',
        'rxjs': 'libs/rxjs'
    };
    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'main.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }
    };
    var ngPackageNames = [
      'common',
      'compiler',
      'core',
      'forms',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router',
      'router-deprecated',
      'upgrade'
    ];

    var ngIndexPackageNames = [
   'http'
    ];
    // Individual files (~300 requests):
    function packIndex(pkgName) {
        packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' };
    }
    // Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/' + pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
    }
    // Most environments should use UMD; some (Karma) need the individual index files
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
    // Add package entries for angular packages
    ngPackageNames.forEach(setPackageConfig);
    ngIndexPackageNames.forEach(packIndex);
    var config = {
        //meta: {
        //    '*.js': {
        //        scriptLoad:true
        //    }
        //},
        map: map,
        packages: packages
    };
    System.config(config);
})(this);

随着 RC.6 的发布,angular2 团队宣布了包配置的新突破性变更

npm packages: code in ESM (ES6 Modules) format is now published at the default location in the npm package with package.json's main entry pointing to an UMD bundle (primarily for node, and webpack 1 users).

If you are using SystemJS to load Angular, you should adjust your SystemJS configuration to point to the UMD bundles (present in the npm package).

Please see this example SystemJS config.