问题描述
我选择了入门Angular2教程格式,并且仅在angularfire2部分.
I picked the getting started with Angular2 tutorial format and only added in the angularfire2 part.
我使用 angularfire2文档页面
下面是我的systemjs.config.js
Below is my systemjs.config.js
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(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',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
'angularfire2': 'npm:angularfire2'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
angularfire2: {
main: 'index.js',
defautExtension: 'js'
}
}
});
})(this);
然后我只是像这样导入它:
Then I am simply importing it like so:
import { AngularFireModule } from 'angularfire2';
然后我不断收到此错误:
Then I keep getting this error:
有任何提示吗?
推荐答案
您的配置将angularfire2映射到node_modules/angularfire2/index.js
,其编写为es6,因此SystemJS尝试使用traceur对其进行编译,但找不到它.
Your config maps angularfire2 to node_modules/angularfire2/index.js
, which is written is es6, so SystemJS tries to compile it using traceur, and can not find it.
最简单的解决方法是对其进行配置,以便将捆绑软件加载到angular2/bundles/angularFire2.umd.js
中,而不是在index.js
中.
The easy fix would be to configure it so it loads the bundle in angular2/bundles/angularFire2.umd.js
, not index.js
.
所以packages
angularfire2: {
main: 'index.js'
需要更改为
angularfire2: {
main: 'bundles/angularFire2.umd.js'
而且,angularFire取决于Firebase,因此,正如@Jonathon Oates在他的回答中所说,您还需要提供Firebase的配置.
Also, angularFire depends on Firebase, so, as @Jonathon Oates said in his answer, you need to provide configuration for Firebase too.
这篇关于带有AngularFire的localhost:3000/traceur SystemJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!