简体   繁体   English

使用webpack最简单的angular2设置

[英]Simplest angular2 setup with webpack

I'm working through egghead.io tutorials on Angular2, but they are still using the beta. 我正在研究Angular2上的egghead.io教程,但它们仍在使用beta。 I'm looking at the docs for Angular2 Quickstart which point to the more up-to-date release candidate, but I can't get the webpack server from the egghead.io lesson to work with the angular2 packages and I'm not really sure where the hangup is. 我正在查看Angular2 Quickstart的文档,该文档指向最新的候选版本,但是我无法从egghead.io课程中获取webpack服务器来使用angular2软件包,但我不是真的确定挂断的位置。

In package.json : 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"
  }

I haven't changed the webpack.config.js from the one presented in the lesson. 我没有改变本课中介绍的webpack.config.js

When I do npm start (run the webpack server) I keep getting 当我执行npm start (运行webpack服务器)时,我不断

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

This would indicate to me that zone.fork is not loading. 这将向我表明zone.fork未加载。 I did update my vendor.ts file to: 我确实将我的vendor.ts文件更新为:

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

but I still get the same error as above. 但我仍然收到与上述相同的错误。 If I include a simple script tag with console.log(zone.fork) it logs a function, so it seems like zone.js is being loaded. 如果我在console.log(zone.fork)包含一个简单的脚本标记,它将记录一个函数,因此好像正在加载zone.js。 I'm not sure why Angular2 won't start or if there is something else I need to include. 我不确定为什么Angular2无法启动,或者我是否需要添加其他内容。

You are importing 您正在导入

"rxjs": "^5.0.0-beta.8",

but rc.1 is only compatible with beta.6 但是rc.1仅与beta.6兼容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM