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

如何修复TypeError: stagedAutoprefixer is not a function错误?

修复 TypeError: stagedAutoprefixer is not a function 问题

这个错误是postcss-loader和autoprefixer版本不兼容导致的——SB Admin模板的默认PostCSS配置适配旧版依赖,新安装的高版本包会让stagedAutoprefixer调用失效,以下是几种修复方案:

方案1:降级依赖到兼容版本

卸载当前的postcss-loader和autoprefixer,安装适配模板的旧版本:

npm uninstall postcss-loader autoprefixer
npm install postcss-loader@3.0.0 autoprefixer@9.8.6 --save-dev

方案2:更新PostCSS配置

如果不想降级,直接修改项目的PostCSS配置:

  1. 在项目根目录新建或修改postcss.config.js,写入兼容新版的配置:
module.exports = {
  plugins: [
    require('autoprefixer')
  ]
}
  1. 打开webpack.config.js,找到postcss相关配置,移除包含stagedAutoprefixer的代码块,比如这类过时配置要删掉:
postcss: function () {
  return {
    plugins: [require('autoprefixer')],
    stagedAutoprefixer: true
  };
}

方案3:清理缓存并重启

完成上述操作后,清理缓存重装依赖,再重启服务:

npm cache clean --force
rm -rf node_modules package-lock.json
npm install
npm start

内容的提问来源于stack exchange,提问作者ThatGuynick

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 15:30:52