Gulp angular2 错误
Gulp error with angular2
我在使用 .gulp at .netCore
部署 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_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 task and gulp-load-plugins not loading plugins
编辑。添加最后 2 个链接
如果有人遇到类似问题,最好的办法是使用日志记录,这通常会找到问题的根源
// 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
);
});
我在使用 .gulp at .netCore
部署 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_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 task and gulp-load-plugins not loading plugins
编辑。添加最后 2 个链接
如果有人遇到类似问题,最好的办法是使用日志记录,这通常会找到问题的根源
// 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
);
});