问题
I am having an error while deploying an angular project using .gulp at .netCore
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
[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. 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 (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
);
});
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
Edit. Adding the last 2 links
回答1:
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
);
});
来源:https://stackoverflow.com/questions/40370893/gulp-error-with-angular2