【问题标题】:Gulp error with angular2angular2 的 Gulp 错误
【发布时间】:2016-11-10 10:26:09
【问题描述】:

在 .netCore 上使用 .gulp 部署 Angular 项目时出错

包.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 ticket,它似乎与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 not defined scripts Gulp taskgulp-load-plugins not loading plugins的方式

编辑。添加最后 2 个链接

【问题讨论】:

    标签: angular .net-core-rc2 gulp-uglify


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-22
      • 2016-02-16
      • 2016-06-06
      • 2016-09-23
      • 2017-03-11
      • 1970-01-01
      • 2016-06-08
      相关资源
      最近更新 更多