question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Malformed PostCSS Configuration - NextJS

See original GitHub issue

Current Behavior

Got an PostCSS Error

Expected Behavior

No error.

Steps to Reproduce

npm i @nrwl/next (use css only, option 1)
nx g @nrwl/next:app some-app

Failure Logs

~ ❯ nx serve some-app

> nx run some-app:serve

We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default.

The following suggested values were added to your tsconfig.json. These values can be changed to fit your project's needs:

	- lib was set to dom,dom.iterable,esnext
	- incremental was set to true

info  - automatically enabled Fast Refresh for 1 custom loader
Error: A PostCSS Plugin was passed as a function using require(), but it must be provided as a string.
Read more: https://nextjs.org/docs/messages/postcss-shape
error - ../../node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!../../node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./pages/styles.css
Error: Malformed PostCSS Configuration
    at Array.forEach (<anonymous>)
[ ready ] on http://localhost:4200

Environment

>  NX   Report complete - copy this into the issue template

  Node : 16.4.0
  OS   : darwin x64
  npm  : 7.18.1

  nx : 13.7.3
  @nrwl/angular : undefined
  @nrwl/cli : 13.7.3
  @nrwl/cypress : 13.7.3
  @nrwl/detox : undefined
  @nrwl/devkit : 13.7.3
  @nrwl/eslint-plugin-nx : 13.7.3
  @nrwl/express : undefined
  @nrwl/jest : 13.7.3
  @nrwl/js : 13.7.3
  @nrwl/linter : 13.7.3
  @nrwl/nest : undefined
  @nrwl/next : 13.7.3
  @nrwl/node : undefined
  @nrwl/nx-cloud : 13.1.2
  @nrwl/react : 13.7.3
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/storybook : 13.7.3
  @nrwl/tao : 13.7.3
  @nrwl/web : 13.7.3
  @nrwl/workspace : 13.7.3
  typescript : 4.5.5
  rxjs : 6.6.7
  ---------------------------------------
  Community plugins:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
Devkant21commented, Feb 21, 2022

@krailler I was able to fix the issue at my end when i used the following in the postcss.config.js file

module.exports = { plugins: [ 'postcss-import', 'tailwindcss/nesting', 'tailwindcss', 'autoprefixer', ] }

Screen Shot 2022-02-21 at 7 17 21 PM

initially my codes were : Screen Shot 2022-02-21 at 7 19 21 PM

I hope it helps.

0reactions
tech3brcommented, Dec 20, 2022

@krailler I was able to fix the issue at my end when i used the following in the postcss.config.js file

module.exports = { plugins: [ 'postcss-import', 'tailwindcss/nesting', 'tailwindcss', 'autoprefixer', ] }

Screen Shot 2022-02-21 at 7 17 21 PM

initially my codes were : Screen Shot 2022-02-21 at 7 19 21 PM

I hope it helps.

thanks bro

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Customizing PostCSS Config - Next.js
To customize the PostCSS configuration, create a postcss.config.json file in the root of your project. This is the default configuration used by Next.js:...
Read more >
Why does create next app install with postcss errors
I change directory to app/client. I run npm run dev. I get this in console... Error: Your custom PostCSS configuration must export a...
Read more >
Malformed PostCSS Configuration - Devkant Swargiary
Hi, I faced this error while trying to incorporate "Dark Mode". My project stack included : Next JS, Tailwind CSS. This error could...
Read more >
Next.js local postcss plugin - Sung.codes
Error: Malformed PostCSS Configuration. Next.js requires an object-based form for postcss plugins. e.g.) So, instead of
Read more >
Malformed PostCSS Configuration - Fueler
This error generally occurs when Nextjs is used with TailwindCSS. The work around is explained in this blog. This was a part of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found