Skip to content

Throws "Error: PostCSS plugin postcss-import requires PostCSS 8" even when PostCSS 8 is installed #435

Closed

Description

@ChildishGiant
PS F:\code\cloverleaf\web> npm view postcss version
8.1.2
PS F:\code\cloverleaf\web> npm run build

> [email protected] build F:\code\cloverleaf\web
> cross-env NODE_ENV=production node --no-deprecation config/webpack/config.js

Translations up to date
Processing translations
Finished processing translations
Build completed in 8.733s

assets by status 118 KiB [cached] 1 asset
runtime modules 1.1 KiB 8 modules
orphan modules 1.07 KiB [orphan] 1 module
modules by path ./node_modules/ 211 KiB 26 modules
modules by path ./src/ 20.8 KiB
  ./src/main.js 20.7 KiB [built] [code generated]
  ./src/style.scss 39 bytes [built] [code generated] [1 error]
modules by path ./data/*.json 2.64 KiB
  ./data/logos.json 1.53 KiB [built] [code generated]
  ./data/themes.json 1.11 KiB [built] [code generated]
./langs/langs.json 159 bytes [built] [code generated]
crypto (ignored) 15 bytes [optional] [built] [code generated]

ERROR in ./src/style.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: PostCSS plugin postcss-import requires PostCSS 8.
Migration guide for end-users:
https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users
    at Processor.normalize (F:\code\cloverleaf\web\node_modules\postcss-loader\node_modules\postcss\lib\processor.js:153:15)
    at new Processor (F:\code\cloverleaf\web\node_modules\postcss-loader\node_modules\postcss\lib\processor.js:56:25)
    at postcss (F:\code\cloverleaf\web\node_modules\postcss-loader\node_modules\postcss\lib\postcss.js:55:10)
    at F:\code\cloverleaf\web\node_modules\postcss-loader\src\index.js:140:12
    at processResult (F:\code\cloverleaf\web\node_modules\webpack\lib\NormalModule.js:576:19)
    at F:\code\cloverleaf\web\node_modules\webpack\lib\NormalModule.js:669:5
    at F:\code\cloverleaf\web\node_modules\loader-runner\lib\LoaderRunner.js:397:11
    at F:\code\cloverleaf\web\node_modules\loader-runner\lib\LoaderRunner.js:252:18
    at context.callback (F:\code\cloverleaf\web\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
    at F:\code\cloverleaf\web\node_modules\postcss-loader\src\index.js:208:9
 @ ./src/main.js 19:0-22

1 ERROR in child compilations
webpack 5.1.3 compiled with 2 errors in 8733 ms

Activity

  1. RyanZim commented on Oct 22, 2020

    @RyanZim
    Collaborator

    Is postcss-loader up to date?

  2. ChildishGiant commented on Oct 22, 2020

    @ChildishGiant
    Author

    Yep, 4.0.4

  3. www-chique commented on Oct 25, 2020

    @www-chique

    Got the same error. Everything else seems up-to-date.
    Following the examples from this article: https://codechips.me/svelte-postcss-and-typescript-with-svite/
    I gave a little bit of context as I am clueless and maybe the error isn't even related to this package. If you need more information, I will try to provide.

  4. RyanZim commented on Oct 27, 2020

    @RyanZim
    Collaborator

    What's the output of npm ls from within the project directory?

  5. songololo commented on Oct 29, 2020

    @songololo

    Same issues here.

    Output from npm ls:

    ├── @fortawesome/[email protected]
    ├── @fortawesome/[email protected]
    ├── @fortawesome/[email protected]
    ├── @vue/[email protected]
    ├── @vue/[email protected]
    ├── @vue/[email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    ├── [email protected]
    └── [email protected]
    
  6. RyanZim commented on Oct 30, 2020

    @RyanZim
    Collaborator

    TBH, I am completely mystified why this is happening. Can somebody make a reduced test case?

  7. songololo commented on Oct 30, 2020

    @songololo

    I think in my case it may be something to do with vuepress calling an older version of postcss under the hood...

  8. aveltras commented on Nov 16, 2020

    @aveltras

    I has this error happen to me while I only had postcss-cli in my explicit dependencies.
    Adding postcss as an explicit dependency fixed it.

  9. simenbrekken commented on Nov 17, 2020

    @simenbrekken

    Just ran into this myself today, the culprit being Storybook that references an older postcss-loader that in turn imported an older postcss-import (https://github.com/storybookjs/storybook/blob/next/lib/core/package.json#L112)

  10. Manubi commented on Nov 29, 2020

    @Manubi

    So what's the solution? :D

  11. simenbrekken commented on Nov 29, 2020

    @simenbrekken

    We ended up pinning postcss-import at 12.x while keeping up-to-date with postcss on the latest branch:

        "postcss": "^8.1.9",
        "postcss-import": "12.0.1",
  12. aslamdoctor commented on Dec 12, 2020

    @aslamdoctor

    @simenbrekken thank you. That worked.

  13. rabota-alexey commented on Jan 26, 2021

    @rabota-alexey

    Just downgrade to
    "postcss-loader": "^4.1.0"

  14. picocodes commented on Feb 10, 2021

    @picocodes

    For anyone else whom @simenbrekken's does not work for, you might have installed postcss-cli globally. Please update the CLI to at least version 8, which loads version 8 of postcss. That's what worked for me.

  15. wallace-sf commented on Feb 13, 2021

    @wallace-sf

    Same here.

    "postcss-import": "^14.0.0",
    "postcss": "^8.2.4"
    
  16. 2 remaining items

  17. RyanZim commented on Mar 31, 2021

    @RyanZim
    Collaborator

    Closing, since no reduced test case has presented itself.

  18. testacode commented on Jul 15, 2021

    @testacode

    I'm not using any post css and I'm getting this when using mini-css-extract-plugin

  19. karladler commented on Oct 11, 2021

    @karladler

    In my case it was a bunch of modules requesting postcss@7 as dependency. See yarn why postcss
    Since the postcss API from 7 to 8 should not differ much I just resolved the issue by adding postcss@8 to the resolutions in package.json

     "resolutions": {
        "postcss": "8"
      }
  20. FrancescoMussi commented on Nov 2, 2021

    @FrancescoMussi

    Thanks @karladler.
    Elegant and effective solution.
    Afterwards I just had to refresh running yarn and the error was gone.

  21. duc168 commented on Dec 14, 2021

    @duc168

    We ended up pinning postcss-import at 12.x while keeping up-to-date with postcss on the latest branch:

        "postcss": "^8.1.9",
        "postcss-import": "12.0.1",

    I had trouble with rollup-plugin-postcss.
    It worked, just run yarn add -D [email protected] and yarn add -D [email protected].

  22. leandro-ortiz-encora commented on Jan 26, 2022

    @leandro-ortiz-encora

    I had a similar error on building a Grafana plugin, but the dependencies are internal to the plugin (I can't update them).
    However, it worked for me just by using yarn instead of npm.

  23. jotapardo commented on Nov 4, 2022

    @jotapardo

    On my file package.json I configured this:

    "dependencies": {
       "postcss-import": "^14.1.0",
       "postcss-loader": "^4.3.0",
       "postcss-mixins": "^9.0.2",
       "postcss-nesting": "^10.1.4",
     },
     "devDependencies": {
       "postcss": "^8.4.18",
     },
     "peerDependencies": {
       "postcss": "^8.4.18"
     },
    

    I noticed the file package-lock.json had a section for an specific package I use (@ckeditor/ckeditor5-dev-utils) and it was requiring specific versions installed:

    "@ckeditor/ckeditor5-dev-utils": {
          "version": "31.1.5",
          "resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-dev-utils/-/ckeditor5-dev-utils-31.1.5.tgz",
          "integrity": "sha512-0hBxhrA0aLkLHxmC3Pc9ruebELeWtOFqK599Lo304CdA3R9UOIYwHnNCXw8NTwnxAtPuvsqAATwbHGEV/tpy9g==",
          "requires": {
               
            "postcss": "^8.4.12",
            "postcss-import": "^14.1.0",
            "postcss-loader": "^4.3.0",
            "postcss-mixins": "^9.0.2",
            "postcss-nesting": "^10.1.4",
               
          },
          "dependencies": {
        [rest of the list of dependences].
          }
        },
    
  24. hongbo-miao commented on Nov 20, 2022

    @hongbo-miao

    Thanks @karladler at #435 (comment) for the yarn solution.

    In my case, I am using npm.

    I didn't use postcss directly. However, when Renovate does lock file maintenance of package-lock.json, it throws error

    PostCSS plugin postcss-discard-comments requires PostCSS 8

    when I build my web app.

    Because some dependencies of dependencies are using PostCSS 7

    Adding overrides:

    "overrides": {
       "postcss": "8.4.19"
    }
    

    in package.json which is similar to resolutions from yarn.

    Then run npm install. Next time, when Renovate does lock file maintenance of package-lock.json, it will use PostCSS 8 instead of PostCSS 7.

    Note

    1. overrides got supported since npm 8.3.0.
    2. peerDependencies does not work for me in this Renovate lock file maintenance case. Some are still using PostCSS 7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions