简体   繁体   English

Angular2的Gulp错误

[英]Gulp error with angular2

I am having an error while deploying an angular project using .gulp at .netCore 在.netCore上使用.gulp部署角度项目时出现错误

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 Error message 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)

After searching about this problem, it seems related with angular-cli as per angular-cli ticket . 在搜索了这个问题之后,似乎与angular-cli有关,与angular-cli ticket有关 The ticket says it was fixed starting beta15, thus I add the latest angular-cli version beta.19-3. 票证说它是从beta15开始固定的,因此我添加了最新的angular-cli版本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. 但是,gulp仍然显示此错误,我不确定是否需要以其他方式引用angular-cli以使其起作用。 I tried with 2 different approaches using gp_uglify and gp_uglify_harmony. 我尝试了两种使用gp_uglify和gp_uglify_harmony的方法。 But still I have the same error. 但是我仍然有同样的错误。

gulpfile.js (task) 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
    );
});

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 似乎缺少一些选项,我也找到了这些帖子,并参考了一个懒惰的选项,但是我在使用它的方式上遇到了困难。$未定义脚本Gulp任务gulp-load-plugins未加载插件

Edit. 编辑。 Adding the last 2 links 添加最后2个链接

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM