在.netCore使用.gulp部署angular项目时出现错误
Package.json
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"@angular/upgrade": "~2.1.0",
"@angular/angular-in-memory-web-api": "~0.1.5",
"@angular/angular-cli": "1.0.0-beta.19-3".
... }
Gulp错误信息
[13:58:40] ReferenceError: options is not defined
at Gulp.<anonymous> ("-"Gulpfile.js:65:18)
at module.exports ("-"node_modulesorchestratorlibrunTask.js:34:7)
at Gulp.Orchestrator._runTask ("-"node_modulesorchestratorindex.js:273:3)
at Gulp.Orchestrator._runStep ("-"node_modulesorchestratorindex.js:214:10)
at "-"node_modulesorchestratorindex.js:279:18
at finish ("-"node_modulesorchestratorlibrunTask.js:21:8)
at "-"node_modulesorchestratorlibrunTask.js:52:4
at f ("-"node_modulesend-of-streamnode_modulesonceonce.js:17:25)
at Transform.onend ("-"node_modulesend-of-streamindex.js:31:18)
at emitNone (events.js:91:20)
at Transform.emit (events.js:185:7)
at "-"node_modulesgulp-cleannode_modulesreadable-streamlib_stream_readable.js:965:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
在搜索了这个问题之后,根据angular-cli票证,它似乎与angular-cli有关。票证上说从beta15开始已经修复了,因此我添加了最新的angular-cli版本beta.19-3。但是,gulp仍然显示此错误,我不确定是否需要以不同的方式引用angular-cli以使其工作。我使用gp_uglify和gp_uglify_harmony尝试了两种不同的方法。但是我仍然有同样的错误。
gulpfile.js(任务)
gulp.task('app', ['app_clean'], function (cb) {
pump([
gulp.src(srcPaths.app),
gp_sourcemaps.init(),
gp_typescript(require('./tsconfig.json').compilerOptions),
//gp_uglify({ mangle: false }),
minifier(options, gp_uglify_harmony),
gp_sourcemaps.write('/'),
gulp.dest(destPaths.app)
],
cb
);
});
似乎有些选项缺失,我也发现这些帖子,参考一个懒惰的选项,但我被困在我应该使用它的方式$ Is未定义脚本Gulp任务和Gulp -load-plugins不加载插件
编辑。添加最后两个链接
如果有人有类似的问题,最好的方法是使用日志记录,这通常会引导到问题的根源
// Compile, minify and create sourcemaps all TypeScript files
// and place them to wwwroot/app, together with their js.map files.
gulp.task('app', ['app_clean'], function (cb) {
pump([
gulp.src(srcPaths.app),
gp_sourcemaps.init(),
gp_typescript(require('./tsconfig.json').compilerOptions),
gp_uglify({mangle:false}).on('error', gutil.log),
gp_sourcemaps.write('/'),
gulp.dest(destPaths.app)
],
cb
);
});