Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin. #5160

Closed
michaelpumo opened this issue Sep 18, 2020 · 38 comments

Comments

@michaelpumo
Copy link

michaelpumo commented Sep 18, 2020

馃悰 bug report

Error when running dev or build with Parcel.

馃帥 Configuration (.babelrc, package.json, cli command)

.babelrc

{
  "presets": [
    "@babel/preset-env"
  ]
}

package.json

{
  "name": "jbg",
  "version": "1.0.0",
  "description": "",
  "main": "assets/js/app.js",
  "scripts": {
    "dev": "parcel watch assets/js/app.js --public-url /wp-content/themes/jbg/dist",
    "build": "parcel build assets/js/app.js --public-url /wp-content/themes/jbg/dist"
  },
  "author": "Michael Pumo",
  "devDependencies": {
    "@babel/core": "^7.11.6",
    "@babel/preset-env": "^7.11.5",
    "autoprefixer": "^10.0.0",
    "eslint": "^7.9.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.4",
    "parcel-bundler": "^1.12.4",
    "postcss-modules": "^3.2.2",
    "prettier": "^2.1.2",
    "sass": "^1.26.11"
  },
  "dependencies": {
    "lazysizes": "^5.2.2",
    "magic-grid": "^3.2.4"
  }
}

馃 Expected Behavior

Project should build without errors.

馃槸 Current Behavior

Full error message:

> parcel watch assets/js/app.js --public-url /wp-content/themes/jbg/dist

馃毃  /Users/michaelpumo/Documents/websites/jbg-wordpress/wp-content/themes/jbg/assets/scss/app.scss:undefined:undefined: PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin.
    at Processor.normalize (/Users/michaelpumo/Documents/websites/jbg-wordpress/wp-content/themes/jbg/node_modules/postcss/lib/processor.js:153:15)
    at new Processor (/Users/michaelpumo/Documents/websites/jbg-wordpress/wp-content/themes/jbg/node_modules/postcss/lib/processor.js:56:25)
    at postcss (/Users/michaelpumo/Documents/websites/jbg-wordpress/wp-content/themes/jbg/node_modules/postcss/lib/postcss.js:55:10)
    at module.exports (/Users/michaelpumo/Documents/websites/jbg-wordpress/wp-content/themes/jbg/node_modules/parcel-bundler/src/transforms/postcss.js:17:19)

馃拋 Possible Solution

Downgrade Autoprefixer to:
"autoprefixer": "^9.8.6"

馃敠 Context

Project was building successfully until after updating autoprefixer package.

馃捇 Code Sample

N/A

馃實 Your Environment

Software Version(s)
Parcel ^1.12.4
Node v10.7.0
npm/Yarn 6.14.8
Operating System macOS Catalina v 10.15.6
@Sam10F
Copy link

Sam10F commented Sep 19, 2020

The "Possible Solution" worked for me.
Waiting for a definitive solution...

@josef256
Copy link

i have the same issue downgrading the version to 9.8.6 fixed it

@johnwmartinez
Copy link

The possible solution worked for me too.

@codemaster138
Copy link

Your possible solution isn't working for me...

@codemaster138
Copy link

Nevermind working now

@Alecto
Copy link

Alecto commented Sep 23, 2020

the same error

@IanLin09
Copy link

same error and possible solution isn't working for me either

@9mm
Copy link

9mm commented Sep 24, 2020

Same problem except I'm using "postcss-cli": "^8.0.0", as well

@adithwip
Copy link

The Possible Solution also worked for me.
Glad I am not the only one.

@marklai1998
Copy link

marklai1998 commented Sep 24, 2020

mine problem is with postcss-loader 4.0, which removed postcss from dependency
install postcss separately will to the job
https://github.com/webpack-contrib/postcss-loader/blob/master/CHANGELOG.md

your problem should be with postcss-modules which postcss is only v7
you need to wait for it to upgrade
https://github.com/css-modules/postcss-modules/blob/master/package.json

@mischnic
Copy link
Member

you need to wait for it to upgrade

PostCSS 8 is backwards compatible with version 7: #5152 (comment)

@marklai1998
Copy link

you need to wait for it to upgrade

PostCSS 8 is backwards compatible with version 7: #5152 (comment)

autoprefixer doesn't

@devongovett
Copy link
Member

This isn't a Parcel issue right? We don't have autoprefixer as a dependency...

@Vassi
Copy link

Vassi commented Sep 24, 2020

I mean, Parcel added post-css and whatnot, all I did (as per the documentation) was add a postcssrc like this:

{
  plugins: {
    'autoprefixer': {}
  }
}

Even though postcss was added @ 8.0.9 (by parcel I assume) I still get this error so something is off?

@mischnic
Copy link
Member

The point is that if you use autoprefixer, you need to install explicitly it yourself, meaning you also control the version of autoprefixer which needs to be at downgrades as per Possible Solution.

@ai
Copy link

ai commented Sep 29, 2020

@devongovett Parcel needs to update PostCSS to be able to use PostCSS 8 plugins

@krishnaUIDev
Copy link

downgrade autoprefixer to 9.8.6. Then it should work fine.

@ai
Copy link

ai commented Oct 9, 2020

Another option is a migration to Parcel 2, which use PostCSS 8

@emshano
Copy link

emshano commented Oct 10, 2020

Cheers, downgrading it works

@williamroger
Copy link

The Possible Solution worked for me too.
Thanks!

@HuangHongRui
Copy link

  1. Emmmm...
  2. Install postcss -D
  3. Done.

@dirad
Copy link

dirad commented Nov 22, 2020

  1. Emmmm...
  2. Install postcss -D
  3. Done.

馃憤

why does this work?

@LukeTOBrien
Copy link

Hi,

I just came across this error today, I'm not sure if it was bundle-text:... or a dependancy I am using in my project.
Your suggested solution worked for me but I don't know why.

@ProLoser
Copy link

  1. Emmmm...
  2. Install postcss -D
  3. Done.

馃憤

why does this work?

It works because it's doing the same thing as explicitly installing an older version of autoprefixer it's explicitly installing a different version than the one that would be implicitly installed from a sub-dependency.

Explicitly pinning autoprefixer keeps it with older but known-to-be-compatible version, while your implementation forces the resolved postcss version to be newer.

I don't really know which solution is better, they will yield similar results (aside from other incompatibilities you may encounter)

@getspooky
Copy link

Hi,
Downgrade your autoprefixer to version 9, use

 "autoprefixer": "9.0.0",

@trapcodeio
Copy link

I have this error when trying to build PostCSS plugin postcss-purgecss requires PostCSS 8

I have do all the fix found on tailwind website.. all to no avail

@DeMoorJasper
Copy link
Member

Not sure why this issue is still open?

There have been multiple suggested and valid solutions to this problem:

  • Use a version of the plugin that is postcss 7 compatible
  • Update to the latest Parcel 2 nightly

@simonwiles
Copy link

The latest Parcel 2 nightly doesn't seem to be pulling in PostCSS8 here. What am I missing?

$ yarn add -D parcel@nightly postcss-cli
...
warning " > postcss-cli@8.3.1" has unmet peer dependency "postcss@^8.0.0".
...

$ yarn run postcss
...
Please install PostCSS 8 or above
error Command failed with exit code 1.

$ yarn why postcss
[1/4] Why do we have the module "postcss"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "postcss@7.0.35"
...

@DeMoorJasper
Copy link
Member

@simonwiles You probably already had it installed, install postcss 8 manually and it should work

@simonwiles
Copy link

@DeMoorJasper -- sorry, I should have made it clearer; this is in a completely new project, e.g.

$ mkdir new-project && cd new-project
$ yarn add -D parcel@nightly postcss-cli
...
warning " > postcss-cli@8.3.1" has unmet peer dependency "postcss@^8.0.0".
...

$ yarn run postcss
...
Please install PostCSS 8 or above
error Command failed with exit code 1.

$ yarn why postcss
[1/4] Why do we have the module "postcss"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "postcss@7.0.35"
...

Installing PostCSS 8 manually does allow postcss-cli to work, but Parcel 2 still appears to be using postcss@7.0.35 (I arrived at this issue trying to debug a problem whereby the postcss-image-inliner plugin works just fine through postcss-cli but doesn't work through Parcel 2, despite identical config -- but I should probably open a separate issue for that with a clean reproducible case).

@DeMoorJasper
Copy link
Member

@simonwiles Seems strange, if you could create a full example project where this happens preferably in a separate issue that would really help us to debug this.

@ai
Copy link

ai commented Dec 30, 2020

@simonwiles do you use latest Parcel 2 nightly? next and beta channels still doesn鈥檛 support PostCSS 8.

@simonwiles
Copy link

Yeah, I've been making sure to use nightly. I'm not sure whether my specific problem with postcss-image-inliner is related to PostCSS 7 vs. 8 or not, tbh, but I wound up here looking for hints. Just doing yarn add -D parcel@nightly postcss-cli in an empty folder results in the output reported above, though, on both the systems I have immediately to hand at least.

I do want to solve the postcss-image-inliner problem though, so I'll open a new issue with a reproducible example (if I don't resolve the problem in the process, as sometimes happens ;) ).

@simonwiles
Copy link

Issue filed: #5551 Thanks :)

jtojnar added a commit to fossar/selfoss that referenced this issue Jan 8, 2021
It requires postcss 8 but Parcel still uses an older one.

parcel-bundler/parcel#5160
@Canuckaholic
Copy link

The following worked for me. Note that I also needed to downgrade the version of postcss-modules from 4.0.0 to 3.2.2.

"autoprefixer": "^9.8.6",
"parcel-bundler": "^1.12.4",
"postcss-modules": "^3.2.2",

@ulises-castro
Copy link

In my case I was trying running a gatsby project, so I had that issue.

The solution was downgrading postcss-pxtorem:
npm install postcss-pxtorem@5.1.1

@chrisSbarrett
Copy link

I still get this issue even on parcel@next. 馃憥

@devopg
Copy link

devopg commented Aug 19, 2021

any news ?
"autoprefixer": "^10.3.1",
"postcss": "^8.3.6",

Error: PostCSS plugin autoprefixer requires PostCSS 8.

virtuoushub added a commit to virtuoushub/redwood that referenced this issue Feb 25, 2022
meant to avoid:

```sh
...
Error: PostCSS plugin autoprefixer requires PostCSS 8.
...
```

redwoodjs#3515 (comment)
parcel-bundler/parcel#5160
virtuoushub added a commit to virtuoushub/redwood that referenced this issue Feb 25, 2022
meant to avoid:

```sh
...
Error: PostCSS plugin autoprefixer requires PostCSS 8.
...
```

redwoodjs#3515 (comment)
parcel-bundler/parcel#5160
virtuoushub added a commit to virtuoushub/redwood that referenced this issue Feb 25, 2022
meant to avoid:

```sh
...
Error: PostCSS plugin autoprefixer requires PostCSS 8.
...
```

redwoodjs#3515 (comment)
parcel-bundler/parcel#5160
virtuoushub added a commit to virtuoushub/redwood that referenced this issue Feb 25, 2022
fix: pin `autoprefixer`

meant to avoid:

```sh
...
Error: PostCSS plugin autoprefixer requires PostCSS 8.
...
```

redwoodjs#3515 (comment)
parcel-bundler/parcel#5160

chore: test using `yarn`'s `resolutions`

see: https://stackoverflow.com/a/66825007
virtuoushub added a commit to virtuoushub/redwood that referenced this issue Feb 25, 2022
fix: pin `autoprefixer`

meant to avoid:

```sh
...
Error: PostCSS plugin autoprefixer requires PostCSS 8.
...
```

redwoodjs#3515 (comment)
parcel-bundler/parcel#5160

chore: test using `yarn`'s `resolutions`

see: https://stackoverflow.com/a/66825007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests