N Kaushik

Solved- “Cannot find module 'autoprefixer'” error tailwindcss

May 23, 2021

“Cannot find module ‘autoprefixer’” error while doing tailwindcss setup in a react project:

This is a common error you will face on setting up tailwindcss in a Reactjs project. Even though autoprefixer is installed, it shows cannot find module autoprefixer error.

It throws this error if you try to init tailwindcss by using:

npx tailwindcss init

How to fix this error:

This error can be fixed easily if you just uninstall and reinstall the dependencies.

Uninstall all tailwind dependencies:

npm uninstall tailwindcss postcss autoprefixer

reinstall the latest:

npm install tailwindcss@latest postcss@latest autoprefixer@latest

Try it again:

npx tailwindcss init

It should work and it will create the tailwind.config.js file.

Reinstall the recommended libs again if npm start is throwing any error:

npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9

Subscribe to my Newsletter

© 2021, nkaushik