使用webpack进行最简单的angular2设置

时间:2016-06-02 01:53:11

标签: javascript angular webpack

我正在研究Angular2上的egghead.io教程,但他们仍在使用测试版。我正在查看Angular2 Quickstart的文档,这些文档指向了更新的候选版本,但我无法从egghead.io课程中获取webpack服务器以使用angular2软件包而且我我不确定挂断的地方。

package.json

  "devDependencies": {
    "html-webpack-plugin": "^2.9.0",
    "ts-loader": "^0.7.2",
    "typescript": "^1.7.3",
    "typings": "^0.6.8",
    "webpack": "^1.12.14",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "@angular/common": "^2.0.0-rc.1",
    "@angular/compiler": "^2.0.0-rc.1",
    "@angular/core": "^2.0.0-rc.1",
    "@angular/http": "^2.0.0-rc.1",
    "@angular/platform-browser": "^2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.1",
    "@angular/router": "^2.0.0-rc.1",
    "@angular/router-deprecated": "^2.0.0-rc.1",
    "@angular/upgrade": "^2.0.0-rc.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.0-beta.8",
    "zone.js": "^0.6.12"
  }

我没有更改课程中提供的webpack.config.js

当我npm start(运行webpack服务器)时,我一直在

  

Error during instantiation of NgZone! (ApplicationRef -> ApplicationRef_ -> NgZone).
  Cannot read property 'fork' of undefined

这表明我zone.fork没有加载。我确实将vendor.ts文件更新为:

import 'zone.js';
import 'reflect-metadata';

但我仍然得到与上面相同的错误。如果我包含一个带有console.log(zone.fork)的简单脚本标记,它会记录一个函数,所以看起来像是加载了zone.js。我不确定为什么Angular2不会启动或者我还需要包含其他内容。

1 个答案:

答案 0 :(得分:-2)

您正在导入

item

但是rc.1只与beta.6兼容