Node.js / Build Tools

vite: command not found

Covers: sh vite command not found · sh: tailwind: command not found · vite command not found — May 2026

📦 npm 📦 pnpm 📦 yarn 🐧 Linux 🍎 macOS
$ vite
bash: vite: command not found

# or in package.json scripts:
sh: vite: command not found

Why Does This Happen?

Vite is almost always installed locally (inside node_modules/.bin/) rather than globally. When you type vite directly in the terminal, your shell looks in PATH — but node_modules/.bin is not in PATH by default.

The correct way to run locally-installed CLI tools is via npx, or by defining them in package.json scripts (which npm/pnpm/yarn run from node_modules/.bin automatically).

⚡ Quick Fix — Run via npx

# Run vite with npx (uses local install): npx vite # Or start dev server: npx vite dev # Build for production: npx vite build

Correct Fix: Use package.json Scripts

The proper setup is to define scripts in package.json. npm/pnpm/yarn automatically use the local node_modules/.bin when running scripts:

{ "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview" } } # Then run: npm run dev pnpm dev yarn dev

Vite Not Installed At All

# Install vite as a dev dependency: npm install -D vite # Or with pnpm: pnpm add -D vite # Or with yarn: yarn add -D vite

Install Vite Globally (not recommended for projects)

# Global install — only do this if you need vite as a standalone CLI: npm install -g vite # Verify: vite --version

Same Fix for Tailwind CSS: sh tailwind command not found

The exact same pattern applies to Tailwind CSS. tailwind is a locally-installed binary — use npx tailwindcss or define it in package.json scripts:

# Instead of: tailwindcss init -p # ❌ fails # Use: npx tailwindcss init -p # ✅ works # Or in package.json: "build:css": "tailwindcss -i input.css -o output.css"