Troubleshoot
Node.jsErrorsLinuxServer Admin

vite: command not found — Fix for npm, npx & pnpm

Fix 'vite: command not found' after installing Vite locally. Vite is a local dev dependency — run it via npx, pnpm exec, or add it to package.json scripts.

May 9, 2026·2 min read

vite: command not found — Fix for npm, npx & pnpm

vite: command not found happens because Vite is installed as a local project dependency, not a global binary. Running vite directly in your shell only works if the local node_modules/.bin directory is in your PATH — which it is not by default.

Fix 1: Use npx (Quickest)

npx vite
npx vite build
npx vite preview

npx looks in node_modules/.bin first, so it finds the locally installed vite without any PATH changes.

Fix 2: Use pnpm exec or yarn (if not using npm)

# pnpm
pnpm exec vite
pnpm exec vite build

# yarn
yarn vite
yarn vite build

The cleanest approach — define scripts that call Vite directly:

{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  }
}

Then run:

npm run dev
npm run build

Package manager scripts automatically add node_modules/.bin to PATH, so vite resolves correctly.

npm install -g vite

This makes vite available everywhere but ties you to a specific version globally. It can conflict with projects that pin a different Vite version. Prefer the npx or script approach.

Fix 5: Vite Not Installed At All

If the project has a package.json but no node_modules yet:

npm install
# or
pnpm install
# or
yarn install

Then run npx vite or npm run dev.

Why vite: command not found After npm install -D vite

Local binaries land in node_modules/.bin/. Running vite in your shell doesn't search there. You can confirm it is installed:

ls node_modules/.bin/vite
# or
./node_modules/.bin/vite --version

If the binary exists, any of the methods above will work.

Common Error: vite: Permission Denied

chmod +x node_modules/.bin/vite

Or reinstall node_modules with:

rm -rf node_modules && npm install

Verify

npx vite --version
# 6.x.x
vite: command not found — Fix for npm, npx & pnpm | VMHeaven Troubleshoot