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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vite] Internal server error: Failed to load PostCSS config #836

Closed
lanzoninicola opened this issue Jul 23, 2022 · 36 comments · Fixed by #844
Closed

[vite] Internal server error: Failed to load PostCSS config #836

lanzoninicola opened this issue Jul 23, 2022 · 36 comments · Fixed by #844
Labels
TYPE: bug Something isn't working

Comments

@lanzoninicola
Copy link

lanzoninicola commented Jul 23, 2022

Qwik Version

"@builder.io/qwik": "0.0.38", "@builder.io/qwik-city": "0.0.23"

Operating System (or Browser)

Win10

Node Version (if applicable)

16.13.1 (Currently using 64-bit executable)

Which component is affected?

Starters / CLI

Expected Behaviour

Opening the initial page in the browser

Actual Behaviour

Steps to reproduce from the terminal:

  1. npm init qwik@latest

  2. Select a name to the project

  3. Select starter: Qwik city

  4. Select server: Cloudflare Pages

  5. Select features: Prettier, Tailwindcss

  6. Move to the project folder

  7. Run npm install

  8. Run npm start

Additional Information

Full error output: qwik_terminal_output.txt

@lanzoninicola lanzoninicola added the TYPE: bug Something isn't working label Jul 23, 2022
@lanzoninicola
Copy link
Author

I don't know, but it seems related to vitejs/vite#5316

@dacki
Copy link

dacki commented Jul 23, 2022

I ran into the same issue on linux. Following the error message I could at least rename the files to postcss.config.cjs (or postcss.config.mjs) and tailwind.config.cjs (or tailwind.config.mjs) as a workaround.

@nnelgxorz
Copy link
Contributor

Qwik City is using Vite 3 now, which went all in on ESM. CommonJS files need to be explicitly named as .cjs, like @dacki said. 👍

@chmich
Copy link

chmich commented Sep 27, 2022

had the same error. i removed the postcss.config.js and it works.
Vite 3.1.3

@YohannesTz
Copy link

Thanks! also worked for me too!

@AGirlHasNoName100
Copy link

mee too @chmich

@PhytonNet
Copy link

I solved this issue by deleting the node_modules directory, and ran npm i again.

@xuyaofang
Copy link

mee too @chmich
Vite 3.2.0

@claudioares
Copy link

Tive esse erro usando o linux ubuntu. Eu removi trocando a extensão .js do arquivo (postcss.config.js) para extensão .cjs ( postcss.config.cjs).

@Aprotix
Copy link

Aprotix commented Nov 30, 2022

I solved this issue by deleting the node_modules directory, and ran npm i again.

This worked instantly

@georginklv
Copy link

I have the same problem with vuetify 3, none of this above works for me. Any ideas ?

@Jays0x
Copy link

Jays0x commented Apr 20, 2023

I had the same issue but when I removed postCSS.config file it worked!

@vinayakkuradia
Copy link

For those who are trying to make Tailwind work with Vite, follow below steps:

  • Rename postcss.config.js to postcss.config.cjs (keep tailwind.config.js as it is)
  • Change the content of postcss.config.cjs as follows:
    module.exports = ({ env }) => ({ plugins: [ require('tailwindcss')(), require('autoprefixer')() ] })

The above is array format for plugins.
Ref: Vite Postcss Config Postcss Load Config

@evn-seyednov
Copy link

evn-seyednov commented Apr 30, 2023

In my case delete type: mode from package.json resolved the issue

@m-tufail
Copy link

vite 4.3.6
instead of cjs use mjs extension.

@phukao
Copy link

phukao commented May 27, 2023

Add
"type": "module"
to package.json

@chmich
Copy link

chmich commented May 27, 2023

What @phukao said also solved another problem for me. Only way to get svelte to run on vite.

@sathishg1990
Copy link

``dfdf

@pedroferreira37
Copy link

@chmich, I'm using Svelte on WSL2. I was getting the same error, but I just run npm install -D tailwindcss postcss autoprefixer and it worked.

@Ishan-Sandaruwan
Copy link

had the same error. i removed the postcss.config.js and it works. Vite 3.1.3

its worked

@jaceksl1
Copy link

had the same error. i removed the postcss.config.js and it works. Vite 3.1.3

the best solution

@nireve
Copy link

nireve commented Aug 23, 2023

Resolved this by upgrading to postcss@8.4.28 and tailwind@3.3.3 (on vite@3.1.3).

@DavilmanXD
Copy link

I ran into the same issue on linux. Following the error message I could at least rename the files to postcss.config.cjs and tailwind.config.cjs as a workaround.

Thaaaaaaaaaaaaaaaaaaaaks

@nasrulhazim
Copy link

  • module.exports = ({ env }) => ({ plugins: [ require('tailwindcss')(), require('autoprefixer')() ] })

nice. it works. thank you so much.

@eugene-makarov
Copy link

Replacing module.exports with export default worked for me

// postcss.config.js

export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  }
}

@akberqureshi361
Copy link

I solved this issue by deleting the node_modules directory, and ran npm i again.

the best solutions thank you

@prathu9
Copy link

prathu9 commented Jan 15, 2024

Replacing module.exports with export default worked for me

// postcss.config.js

export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  }
}

This is bext solution.

@adamaslan
Copy link

adamaslan commented Mar 26, 2024

not working for me
"postcss": "^8.4.38",
"tailwindcss": "^3.4.1",
"vite": "^5.2.0"

my error is similar tho:
[vite] Internal server error: [postcss] Unexpected token, expected "(" (4:16)
Plugin: vite:css
File: /Users/adamaslan/code/fractal/three-fun/src/index.css:undefined:NaN

@wmertens
Copy link
Member

wmertens commented Mar 27, 2024

@adamaslan looks like there's a missing ( on line 4 in your index.css file that it doesn't expect.

@johnston75
Copy link

VITE v4.5.3. I rename postcss.config.js and this works for me. thanks....

Anyway, there is still no fixed solution to this problem, the solutions still vary. I don't know the root cause.

@KING9045
Copy link

For those who are trying to make Tailwind work with Vite, follow below steps:

* Rename `postcss.config.js` to `postcss.config.cjs` (keep `tailwind.config.js` as it is)

* Change the content of `postcss.config.cjs` as follows:
  `module.exports = ({ env }) => ({ plugins: [ require('tailwindcss')(), require('autoprefixer')() ] })`

The above is array format for plugins. Ref: Vite Postcss Config Postcss Load Config

I had same issue and it worked for me using the above reference

@VybzTech
Copy link

I ran into the same issue on linux. Following the error message I could at least rename the files to postcss.config.cjs and tailwind.config.cjs as a workaround.

This helped me too 19/04/24

@willzfrank
Copy link

willzfrank commented Apr 24, 2024

These are the steps that worked for me:

  1. I converted postcss.config.js to postcss.config.cjs.
  2. In my package.json, I updated "type": "module" in my package.json.
  3. I updated my tailwind.config.js file as follows:
/** @type {import('tailwindcss').Config}*/
export const content = ['./src/**/*.{js,jsx,ts,tsx}']
export const theme = {
  extend: {},
}
export const plugins = []
  1. Finally, I ran npm run dev.

@omerwaqaskhan
Copy link

"postcss": "^8.4.38",
"postcss-import": "^16.1.0",
"tailwindcss": "^3.4.3",
"vite": "^5.2.10"

Only deleting the file postcss.config.js works.
Nothing else works

zirodev23 pushed a commit to zirodev23/lara10videolist that referenced this issue May 8, 2024
@andreakouakou09
Copy link

with VITE 4.5.3 Rename postcss.config.js to `postcss.config.mjs

@Michaecyber
Copy link

removed the postcss.config.js and it will works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.