-更新
所以我更新了我的任务,现在我有了以下内容,问题是当它进入规范时,第一行如下所示
import {Injector, provide} from "angular2/core";不幸的是,这里引用的不是node_modules/angular2目录,而是项目根目录!
var jasmine = require('gulp-jasmine');
var System = require('systemjs');
gulp.task('newtest', () => {
System.config({
baseURL: "/",
transpiler: 'typescript',
defaultJSExtensions: true,
path: {
"node_modules*": "node_modules/*"
},
packages: {
"app": {
"defaultExtension": "js"
}
},
maps:{
"angular2": "/node_modules/angular2",
},
});
Promise.all([
System.import('app/assets/services/config.service.spec'),
]).then(function(){
gulp.src(['app/assets/services/config.service.spec'])
.pipe(jasmine())
}).catch(console.error.bind(console));
});-旧
因此,我可能是个新手,但我正在尝试使用gulp来构建、调试和测试我的演示解决方案。这个应用程序使用的是Angular 2,Gulp,SystemJS,Gulp-tslint和Gulp-Jasmine,然而我无法让Gulp-Jasmine在不跌倒的情况下运行。它的抱怨如下:
events.js:141
throw er; // Unhandled 'error' event
^
TypeError: Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:2981:17)
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:3655:29)
at SystemJSNodeLoader. (D:\ng2demo\node_modules\systemjs\dist\system.src.js:4142:33)
at SystemJSNodeLoader.reduceRegister_ (D:\ng2demo\node_modules\systemjs\dist
\system.src.js:4142:33)
at SystemJSNodeLoader.pushRegister_ (D:\ng2demo\node_modules\systemjs\dist\system.src.js:2699:14)
at SystemJSNodeLoader.SystemJSLoader.register (D:\ng2demo\node_modules\syste
mjs\dist\system.src.js:2937:10)
at Object. (D:\ng2demo\app\assets\services\config.service.spec.js
:4:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)它试图运行的JS文件是用TypeScript编写的规范,并使用gulp-typescript转换为JS。因此,该文件的第一行是:
System.register(['angular2/core', 'angular2/http', 'angular2/http/testing',
./config.service'], function(exports_1, context_1) {
//Do Stuff
});就是这条线有问题,有什么想法吗?
发布于 2016-04-24 04:33:39
您似乎在此行中缺少一个':
./config.service'], function(exports_1, context_1) {应该是:
System.register(['angular2/core', 'angular2/http', 'angular2/http/testing',
'./config.service'], function(exports_1, context_1) {
//Do Stuff
});https://stackoverflow.com/questions/36815540
复制相似问题