在参数列表后获取:SyntaxError:缺少),但无法找出hulpfile.js出了什么问题 [英] Getting: SyntaxError: missing ) after argument list but can't find out whats wrong with hulpfile.js

查看:96
本文介绍了在参数列表后获取:SyntaxError:缺少),但无法找出hulpfile.js出了什么问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下gulp文件中启动"gulp default"时遇到错误.我无法弄清楚该文件出了什么问题.

Hi I'm getting an error starting 'gulp default' with the following gulp file. 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.

推荐答案

请参见不要使用 errLogToConsole ,它似乎不再受支持.

Don't use errLogToConsole it doesn't appear to be supported anymore.

.pipe(sass(errLogToConsole: true, outputStyle: 'compressed'))

将其更改为

.pipe(sass({outputStyle:'compressed'}).on('error',sass.logError))

.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))

gulp-sass选项一样.您先前的错误可能是由于不要在{}大括号中包含您的选项(这是一个对象).

as in gulp-sass options. Your earlier error was probably due to not including your options in {} braces (it is an object).

:

与您的其他错误相同

.pipe(autoprefixer(browsers: ['last 2 versions', '> 5%', 'Firefox ESR']))

应该是

.pipe(autoprefixer( { browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] } ))

注意花括号.通常,gulp插件的选项是对象,因此需要将其包装在大括号{}中.

Note the curly braces. Usually the options to gulp plugins are objects so they need to be wrapped in braces {}.

这篇关于在参数列表后获取:SyntaxError:缺少),但无法找出hulpfile.js出了什么问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆