I'm trying to update my tailwindcss but I encountered this issue:
PostCSS plugin tailwindcss requires PostCSS 8
I've tried:
npm uninstall tailwindcss postcss autoprefixer
npm i tailwindcss@latest postcss@latest autoprefixer@latest
But I see the above eror. I'm curious that the error indicates that I need to have version postcss 8 or higher, then why doesn't it work while having its version "8.2.4" in "package.json". Here is how my package.json looks like:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@coreui/react-chartjs": "^2.1.0",
"@craco/craco": "^6.2.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^1.3.4",
"chart.js": "^4.0.1",
"dayjs": "^1.11.7",
"firebase-tools": "^9.23.3",
"react": "^17.0.2",
"react-chartjs-2": "^5.0.1",
"react-circular-progressbar": "^2.1.0",
"react-copy-to-clipboard": "^5.1.0",
"react-device-detect": "^2.2.2",
"react-dom": "^17.0.2",
"react-loader-spinner": "^5.3.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-toastify": "^8.1.0",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.4.14",
"postcss": "^8.4.21",
"tailwindcss": "^3.3.1"
}
}
Also, tried deleting node_modules then adding again via npm i
Note:
I don't need this version of tailwind(v2)
npm install tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
instead, I want to have tailwindcss v3.
Edit:
Here is how my craco.config.js looks like:
// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
}
You don't need to install Post css for Tailwind V3. Try this:
npm uninstall tailwindcss postcss autoprefixernpm install -D tailwindcss