Angular2的Gulp错误 [英] Gulp error with angular2

查看:117
本文介绍了Angular2的Gulp错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.netCore上使用.gulp部署角度项目时出现错误

I am having an error while deploying an angular project using .gulp at .netCore

Package.json

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_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask ("-"\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep ("-"\node_modules\orchestrator\index.js:214:10)
at "-"\node_modules\orchestrator\index.js:279:18
at finish ("-"\node_modules\orchestrator\lib\runTask.js:21:8)
at "-"\node_modules\orchestrator\lib\runTask.js:52:4
at f ("-"\node_modules\end-of-stream\node_modules\once\once.js:17:25)
at Transform.onend ("-"\node_modules\end-of-stream\index.js:31:18)
at emitNone (events.js:91:20)
at Transform.emit (events.js:185:7)
at "-"\node_modules\gulp-clean\node_modules\readable-stream\lib\_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票证相关联。票证说它是从beta15开始固定的,因此我添加了最新的angular-cli版本beta.19-3。但是,gulp仍然显示此错误,我不确定是否需要以其他方式引用angular-cli以使其起作用。我尝试了两种使用gp_uglify和gp_uglify_harmony的方法。但是我仍然有同样的错误。

After searching about this problem, it seems related with angular-cli as per angular-cli ticket. The ticket says it was fixed starting beta15, thus I add the latest angular-cli version beta.19-3. However, gulp is still showing this error, I am not sure if I need to reference angular-cli in a different way to make it work. I tried with 2 different approaches using gp_uglify and gp_uglify_harmony. But still I have the same error.

gulpfile.js(任务)

gulpfile.js (task)

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
    );
});

似乎缺少一些选择,我也找到了这些帖子,指的是一个懒惰的选择,但是我陷入了我应该使用它的方式 $未定义脚本Gulp任务 gulp-load-plugins未加载插件

It seems some options are missing, I also find these posts, refer about a lazy option, but I am stuck on the way I should use it $ Is not defined scripts Gulp task and gulp-load-plugins not loading plugins

编辑。添加最后2个链接

Edit. Adding the last 2 links

推荐答案

如果有人遇到类似的问题,最好的方法是使用日志记录,这通常可以指导问题的根源

If someone has a similar issue, the best way is using the logging, this will often guide to the root of the problem

// 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
    );
});

这篇关于Angular2的Gulp错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆