I am currently learning Laravel version 8 and encountered an issue while trying to install Tailwind CSS using the npm command.
npm install tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
Here is a detailed step-by-step explanation of what I did:
- Installed a fresh Laravel 8 using the Laravel installer.
- Ran
npm install
. - Executed
.npm install tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
- Ran
npx tailwindcss init
. - Edited the
tailwind.config.js
file as follows:
module.exports = {
purge: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
],
darkMode: false,
theme: {
extend: {}
},
variants: {
extend: {}
},
plugins: []
};
Updated the webpack.mix.js
file:
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
require("autoprefixer"),
]);
Imported Tailwind CSS in the app.css
file:
@import "tailwind/base";
@import "tailwind/components";
@import "tailwind/utilities";
After running npm run dev
, I encountered an error in the command line. Any help would be greatly appreciated.