Search code examples
tailwind-css

The npx tailwindcss command is not working. It showing error module not found


When I am running npx tailwindcss init command It showing following error:

'H' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module 'C:\Users\tailwindcss\lib\cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.11.1

The others files already created: node_modules, package-lock.json and package.json. This is the screenshot of other files. (https://i.sstatic.net/02PQ8.jpg) I have tried the following commands to fix: 1.npm install tailwindcss postcss autoprefixer 2. npx tailwindcss-cli@latest init -p Others commands are working like: node -v, npm init and npm -vbut just tailwindcss file is not creating. I want to know the reasong as well as solution that why is not working and how to resolve this issue. Thank you!


Solution

  • The error "'H' is not recognized as an internal or external command," means that your code is trying to run "H" as a command, but it can't find it.

    Try installing Tailwind CSS as a dev dependency: npm i -D tailwindcss

    Also, check that you're in the project's root folder when running commands.