Gulp POSTSS错误:[对象]不是POSTSS插件

Gulp POSTSS错误:[对象]不是POSTSS插件,gulp,postcss,Gulp,Postcss,错误来自postss插件,我想我可能写错了 我正在尝试将cssnano和autoprefixer添加到postsss插件中 gulp/node_modules/gulp-postcss/node_modules/postcss/lib/processor.js:143 throw new Error(i + ' is not a PostCSS plugin'); ^ Error: [object Object] is not a PostCSS plugin

错误来自
postss
插件,我想我可能写错了

我正在尝试将
cssnano
autoprefixer
添加到
postsss
插件中

gulp/node_modules/gulp-postcss/node_modules/postcss/lib/processor.js:143
        throw new Error(i + ' is not a PostCSS plugin');
        ^

Error: [object Object] is not a PostCSS plugin
    at Processor.normalize (/Applications/XAMPP/xamppfiles/htdocs/sites/gulp/node_modules/gulp-postcss/node_modules/postcss/lib/processor.js:143:15)
    at new Processor (/Applications/XAMPP/xamppfiles/htdocs/sites/gulp/node_modules/gulp-postcss/node_modules/postcss/lib/processor.js:51:25)
    at postcss (/Applications/XAMPP/xamppfiles/htdocs/sites/gulp/node_modules/gulp-postcss/node_modules/postcss/lib/postcss.js:73:10)
    at Transform.stream._transform (/Applications/XAMPP/xamppfiles/htdocs/sites/gulp/node_modules/gulp-postcss/index.js:47:5)
    at Transform._read (_stream_transform.js:167:10)
    at Transform._write (_stream_transform.js:155:12)
    at doWrite (_stream_writable.js:300:12)
    at writeOrBuffer (_stream_writable.js:286:5)
    at Transform.Writable.write (_stream_writable.js:214:11)
    at DestroyableTransform.ondata (/Applications/XAMPP/xamppfiles/htdocs/sites/gulp/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:531:20)
Mac-a45e60e72dad:gulp JoeKonst$ 
我的代码:

// Dependancies
var gulp = require('gulp'),
    browserSync = require('browser-sync'),
    plumber = require('gulp-plumber'),
    autoprefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    compass = require('gulp-compass'),
    rename = require('gulp-rename'),
    nano = require('cssnano'),
    del = require('del'),
    postcss = require('gulp-postcss'),
    sass = require('gulp-sass');

// Styles
gulp.task('styles', function(){
    gulp.src('sass/main.scss')
    .pipe(sass())
    .pipe(postcss([autoprefixer({browsers: ['last 2 versions']}), nano()]))
    .pipe(gulp.dest('css/'));

    gulp.watch('sass/**/*.scss', ['styles']);
});

// Tasks
gulp.task('default', ['styles']);
您正在使用该软件包。这只是原始软件包的一个包装器,将其转换为一个gulp插件,因此您可以执行
.pipe(autoprefixer())

但是
postss
要求的是原始软件包本身,而不是gulp插件

因此,与此相反:

autoprefixer = require('gulp-autoprefixer'),
您需要安装
autoprefixer
软件包并执行以下操作:

autoprefixer = require('autoprefixer'),

如果您使用的是
autoprefixer 10
,您可能会再次遇到该问题,github存在与此相关的问题,并提供了一些链接和说明:

tl;博士:

  • 对于
    postscs cli
    gulp postsss
    您必须等待更新,对于
    PostStylus
    您可能永远无法获得更新
  • 或添加
    postss
    作为附件

@rizkit-我找到了最简单的方法。只需运行
npmi-d postsss
,问题就解决了

基本上,您需要依赖项中的
gulppostsss
postsss
插件才能正常工作。我假设
gulp postsss
插件需要在项目中更新
postsss
包参考以正确修复它,因此我们只需要在将来包含
gulp postsss

Tailwindcss&React问题
对于任何在使用tailwindcss设置react项目时遇到上述问题的人来说,运行
npm i postsss-D
对我来说很有效。

在我的情况下,我仍然会遇到这个错误,并且找不到build-manifest.json 当我升级到下一代js v 10并升级了tailwind、autoprefixer和postcss时

我必须升级纱线以最终消除错误

my package.json中更新的开发依赖项如下:

  "devDependencies": {
    "autoprefixer": "^10.2.6",
    "babel-plugin-inline-react-svg": "^1.1.1",
    "postcss": "^8.3.0",
    "tailwindcss": "^2.1.2"
  }

gulp cssnano也有同样的问题-它也不能用作POSTSS插件。必须要求并使用“cssnano”而不是“gulp cssnano”。从视觉上看,它看起来几乎一样,作为一个大口大口大口的新手,我必须说这是ez所忽略的。额外的好处:现在你可以“突然”在你的autoprefixer中使用参数:`.pipe(postss([autoprefixer({browsers:['iOS…]})])`使用
npm i-D降级到Autoprefixer v9autoprefixer@9
也是一个选项。
npm i-d PostCs
为我工作!我升级到Ng12并遇到了这个问题。