[英]Getting: SyntaxError: missing ) after argument list but can't find out whats wrong with hulpfile.js
Hi I'm getting an error starting 'gulp default' with the following gulp file. 嗨,我收到以下gulp文件启动'gulp default'错误。 I cannot figure out whats wrong with the file.
我无法弄清楚该文件出了什么问题。
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var input = './scss/**/*.scss';
var output = './css';
gulp.task('sass', function() {
return gulp.src(input)
.pipe(sourcemaps.init())
.pipe(sass(errLogToConsole: true, outputStyle: 'compressed'))
.pipe(autoprefixer(browsers: ['last 2 versions', '> 5%', 'Firefox ESR']))
.pipe(sourcemaps.write())
.pipe(gulp.dest(output))
.pipe(browserSync.stream());
});
// Watch files for change and set Browser Sync
gulp.task('watch', function() {
// BrowserSync settings
browserSync.init({
proxy: "mydomain.loc",
files: "./css/styles.css"
});
// Scss file watcher
gulp.watch(input, ['sass'])
.on('change', function(event) {
console.log('File' + event.path + ' was ' + event.type + ', running tasks...')
});
});
// Default task
gulp.task('default', ['sass', 'watch']);
I've allready reinstalled node and all the package won't solve the problem though. 我已经准备好重新安装节点,但是所有软件包都无法解决问题。
See Gulp Sass with errLogToConsole: true still stopping my other watch tasks and Gulp-generated source maps don't work in Chrome . 请参阅带有errLogToConsole的Gulp Sass:true仍在停止我的其他监视任务,并且Gulp生成的源地图在Chrome中不起作用 。
Don't use errLogToConsole it doesn't appear to be supported anymore. 不要使用errLogToConsole,它似乎不再受支持。
.pipe(sass(errLogToConsole: true, outputStyle: 'compressed'))
Change that to 更改为
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) .pipe(sass({outputStyle:'compressed'})。on('error',sass.logError))
as in gulp-sass options. 就像在gulp-sass选项中一样。 Your earlier error was probably due to not including your options in {} braces (it is an object).
您之前的错误可能是由于未在{}括号中包含选项(这是一个对象)。
[EDIT] : [编辑]:
And your other error is the same 和你的其他错误是一样的
.pipe(autoprefixer(browsers: ['last 2 versions', '> 5%', 'Firefox ESR']))
should be 应该
.pipe(autoprefixer( { browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] } ))
Note the curly braces. 注意花括号。 Usually the options to gulp plugins are objects so they need to be wrapped in braces {}.
通常,gulp插件的选项是对象,因此需要将其包装在大括号{}中。
Tried to change that. 试图改变这一点。 It directly gives the same error on an other line:
它直接在另一行上给出相同的错误:
/Users/hmook/Documents/Development/lvdb/gulpfile.js:14
.pipe(autoprefixer(browsers: ['last 2 versions', '> 5%', 'Firefox ESR']))
^^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.