我正在为Angular 2使用一个简单的Brunch.io骨架。可以找到完整的源代码here。
我现在正尝试使用SystemJS加载Angular。它失败了。
首先我将systemjs添加到我的package.json并运行npm install:
// [..]
"dependencies": {
"angular2": "2.0.0-beta.11",
"systemjs": "0.19.24",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"sass-brunch": "^2.0.0",
"zone.js": "0.6.5"
},
// [..]
然后我在vendor.ts中要求它导入所有javascript:
// ./app/vendor.ts
import 'es6-shim';
import 'es6-promise';
import 'zone.js';
// Fix for error "ZoneSpec required"
// https://github.com/angular/angular/issues/7660
// http://stackoverflow.com/questions/36112548/setup-angularjs-2-project-using-jspm
import 'zone.js/dist/long-stack-trace-zone';
import 'reflect-metadata';
// Add systemjs
import 'systemjs';
if ('production' === 'BRUNCH_ENVIRONMENT') {
let ngCore = require('angular2/core');
ngCore.enableProdMode();
}
// Angular 2
import 'angular2/platform/browser';
import 'angular2/platform/common_dom';
import 'angular2/router';
import 'angular2/http';
import 'angular2/core';
// RxJS
import 'rxjs';
在此错误中编译结果:
error: Resolving deps of node_modules/when/es6-shim/Promise.js failed.
Could not load module '../format' from '/APP/node_modules/when/es6-shim'.
Make sure the file actually exists. ; Resolving deps of node_modules/systemjs/dist/system.src.js
failed. Improperly-cased require: 'fs' in /APP/node_modules/systemjs/dist/system.src.js
现在我缺乏智慧,需要一些帮助。