Unable to run npx tailwindcss init with TailwindCSS 4.0.0: command not found
Problem
I am having issues installing the latest version of Tailwind! In my case, I’m not using Vite, but I encountered this problem after attempting to install the latest version of TailwindCSS in an existing project. Environment: • OS: macOS Sequoia Version 15.2 (24C101) • Node.js version: 18.17.0 • TailwindCSS version: ^4.0.0 Steps I took: Installed TailwindCSS using the command (and its installing the latest version: 4.0.0): npm install -D tailwindcss Tried initializing the TailwindCSS configuration: npx tailwindcss init Actual Behavior: sh: tailwind: command not found -- This error indicated that the tailwindcss package was not installed globally, but it actually was! Surprisingly, when I switched to an older version of TailwindCSS, the command worked as expected.
Error Output
error indicated that the tailwindcss package was not installed globally, but it actually was! Surprisingly, when I switched to an older version of TailwindCSS, the command worked as expected.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix TailwindCSS Command Not Found Error on macOS
The error occurs because the local installation of TailwindCSS is not recognized in the command line. This can happen if the local node_modules/.bin directory is not in the PATH, or if the command is being run in a shell session that does not have access to the local binaries.
Awaiting Verification
Be the first to verify this fix
- 1
Check Local Installation
Ensure that TailwindCSS is correctly installed in your project. Verify that the package exists in your node_modules directory.
bashls node_modules/tailwindcss - 2
Use npx to Run TailwindCSS
Instead of running 'tailwindcss init', use 'npx tailwindcss init' to ensure that the command is executed using the local version of TailwindCSS.
bashnpx tailwindcss init - 3
Check PATH for Local Binaries
Make sure that the local node_modules/.bin directory is included in your PATH. You can add it temporarily by running 'export PATH=$PATH:./node_modules/.bin'.
bashexport PATH=$PATH:./node_modules/.bin - 4
Install TailwindCSS Globally (if needed)
If you prefer to use TailwindCSS commands globally, install it globally using npm. This is not necessary if you are using npx, but can be useful for other projects.
bashnpm install -g tailwindcss - 5
Verify Installation
After following the above steps, verify that the command works by running 'npx tailwindcss --version' to check if TailwindCSS is recognized.
bashnpx tailwindcss --version
Validation
Confirm that the command 'npx tailwindcss init' runs without errors and creates a tailwind.config.js file in your project directory. Additionally, check that 'npx tailwindcss --version' outputs the correct version of TailwindCSS.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep