I’m trying to set up Tailwind CSS in my Laravel project following the official Tailwind CSS documentation, but I’m encountering an issue when running the npx tailwindcss init -p
command.
After I installed the required npm packages by running:
npm install -D tailwindcss postcss autoprefixer
After that my package.json
looks like this:
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"autoprefixer": "^10.4.19",
"axios": "^1.6.4",
"laravel-vite-plugin": "^1.0",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"vite": "^5.0"
}
}
However, when I run npx tailwindcss init -p
, I get the following error:
'Intermediatejob-boardnode_modules.bin' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:1051
throw err;
^
Error: Cannot find module 'D:New FolderProgrammingLaravelfrom the coursestailwindcsslibcli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
at Module._load (node:internal/modules/cjs/loader:901:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.8.1
Things I’ve tried:
- Reinstalling dependencies after deleting
node_modules
andpackage-lock.json
. According to this answer. - Clearing the npm cache:
npm cache clean --force
- When I created the Laravel project, I created with
--prefer-dist
flag. So, try creating the Laravel project without the--prefer-dist
flag.
None of these steps resolved the issue. Is there something I’m missing or doing wrong?
Additional Details:
- Node.js version: v20.8.1
- npm version: 10.8.1
- Operating System: Windows 11
Any help would be greatly appreciated!