adding router service in angular2-todo and errors: Uncaught ReferenceError: require is not defined

adding router service in angular2-todo and errors: Uncaught ReferenceError: require is not defined

我正在学习 angular2 并在 github 上玩 Colin Eberhardt 的教程项目 - https://github.com/ColinEberhardt/angular2-todo

为了扩展它,我想向它添加 http "router" 服务,以便它可以显示多个页面。我把它克隆到: https://github.com/tanchifu/angular2-todo

修改后的项目构建良好,没有错误,但我遇到的问题是应用程序完全无法显示。浏览器控制台显示以下错误消息:

Uncaught ReferenceError: require is not defined     :3000/app/bootstrap.js:2

Uncaught TypeError: Cannot read property 'split' of undefined    angular2-polyfills.js:143

我想我遇到了 systemjs 或 requirejs 包含的问题。所以我玩了 tsconfig.json、gulpfile.js,但是尝试了几个小时后,我感到非常沮丧并放弃了。如果有人能看一看,我将不胜感激,这一定是图书馆里的东西,包括我搞砸了。

我会将 tsconfig.json 文件中 module 属性的值从 commonjs 更改为 system:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "declaration": false,
    "stripInternal": true,
    "module": "system", // <------------
    "moduleResolution": "node",
    "noEmitOnError": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "target": "es5"
  },
  (...)
}