You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

gulp-autoprefixer报错‘autoprefixer is not a function’排查求助

gulp-autoprefixer报错‘autoprefixer is not a function’排查求助

各位大佬好,我碰到个闹心的问题:这套Gulp代码我在其他项目里跑都顺得很,但这次运行clean_makes_css任务时,直接抛出了autoprefixer is not a function的错误。

我特意加了个checkFunc任务排查模块加载情况,结果发现gulp-concat是正常的函数类型,但gulp-autoprefixer就不是。我已经确认gulp-autoprefixer包已经安装成功了,项目依赖里能看到它,可就是没法正常调用,实在搞不懂哪里出问题了,有没有过来人给指条路?

我的代码如下:

var gulp = require('gulp');
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var css_minify = require('gulp-clean-css');

gulp.task('checkFunc', function (){
  if (typeof concat === 'function'){
    console.log('concat is a function');
  }else {
    console.log('concat is not a function');
  }
  if (typeof autoprefixer === 'function'){
    console.log('autoprefixer is a function');
  }else {
    console.log('autoprefixer is not a function');
  }
});

gulp.task('clean_makes_css', function () {
  // return gulp.src(['common_css/upper_section.css', 'common_css/popup.css', 'common_css/make.css', 'common_css/cart.css', 'common_css/login.css', 'common_css/receipt.css', 'common_css/orderhistory.css', 'common_css/google_translate.css'])
  return gulp.src(['common_css/upper_section.css', 'common_css/popup.css'])
    .pipe(concat('makes.min.css'))
    .pipe(autoprefixer('last 3 versions'))
    .pipe(css_minify({ keepbreaks: true }))
    .pipe(gulp.dest('dest_css'));
});

对了,我装的是最新版的gulp-autoprefixer,会不会是和当前Gulp版本不兼容?或者是调用方式悄悄改了?我之前一直都是这么写的啊...

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 14:09:32