直接用编译好的.js文件的话system.config.js是这样的

(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/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',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      // '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',


    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: '../test.main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

其中

main: '../test.main.js',
        defaultExtension: 'js'

里面必须写成js,如果忘了将.ts文件编译成.js文件的话,会报错,提示“GET http://127.0.0.1:8080/ (Not Found)”
如果是直接用.ts文件的话,system.config.js应该是这样的

(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },


    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/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',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      // '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript/lib/plugin.js',
      'typescript':                'npm:typescript/lib/typescript.js',


    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: '../test.main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

相比上面,不但更改了两处.js变成.ts,还增加了两个部分
新增第一部分代码

// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },

新增第二部分代码

      'ts':                        'npm:plugin-typescript/lib/plugin.js',
      'typescript':                'npm:typescript/lib/typescript.js',

如果只增加第二部分代码,不增加第一部分代码,报错仍然是“GET http://127.0.0.1:8080/ (Not Found)”,如果只增加第一部分代码,不增加第二部分代码,报错会是“GET http://127.0.0.1:8080/ts (Not Found)”或者“GET http://127.0.0.1:8080/typesript (Not Found)”之类的。
搜狗截图20170126212205
平时测试代码,懒得每次编译ts就直接用这种模式。

随机文章

发现你的手机上多了一个google setting了吗
发现你的手机上多了一个google setting了吗

大家快来领万网139元域名代金券
大家快来领万网139元域名代金券

U盘安装ubuntu linux, 重启后屏幕一直停留在Peter Anvin et al
U盘安装ubuntu linux, 重启后屏幕一直停留在Peter Anvin et al

安装运行angular2
安装运行angular2

终于实现win主机wordpress评论回复发送邮件通知
终于实现win主机wordpress评论回复发送邮件通知

Java基础第十二讲:面向对象基础(六)
Java基础第十二讲:面向对象基础(六)

相关文章

angular表单验证$parsers和$validators方式区别
angular表单验证$parsers和$validators方式区别

今天道招网重新用起了以前的纳奇广告联盟
今天道招网重新用起了以前的纳奇广告联盟

里程碑换屏图文教程
里程碑换屏图文教程

windows平台Emacs单实例原理、设置及右键菜单的添加
windows平台Emacs单实例原理、设置及右键菜单的添加

java双缓冲技术
java双缓冲技术

oppo手机通讯录格式 csv 制作
oppo手机通讯录格式 csv 制作

内容分享:道招
本文链接:angularjs2会报错“GET http://127.0.0.1/traceur 404 (Not Found)”
道招声明:除特别标注或作者不详外,本站所有文章均为原创,转载请注明。欢迎共同关注互联网!