Vite Is Not Recognized As An Internal Or External Command | Fix Steps

This Vite command error shows up when your shell can’t find the Vite binary; run it via project scripts or reinstall it so it’s on PATH.

You type npm run dev and your terminal answers with the Windows line: “vite is not recognized as an internal or external command, operable program or batch file.” It’s annoying because it feels like you did everything right.

It’s common on fresh installs.

The good news is that this error has a small set of root causes. Once you match your case, the fix is usually a two-minute change, not a full rebuild of your project.

What This Error Means In Plain Terms

Vite is a Node package that ships a command-line entry called vite. When you run that command, your shell looks through a list of folders (your PATH) to find an executable file named vite, vite.cmd, or vite.ps1 depending on your system.

If the file isn’t in any of those folders, you’ll see the “not recognized” message. In practice, that happens in three common situations: Vite isn’t installed in the project, you’re running the command from the wrong place, or the folder that holds Node global executables isn’t on PATH.

Fast Match Table

Use this table to spot the likely cause before you change anything.

Where It Fails Likely Cause Fast Fix
npm run dev inside a Vite app Dependencies not installed, or node_modules missing Run npm install then retry
Typing vite directly Vite installed locally, not globally Run npx vite or use npm run dev
After global install Global npm bin folder not on PATH Add npm’s global bin to PATH, restart terminal
Only in one terminal app Shell session didn’t reload PATH Close all terminals, reopen, then retry

Fast Checks That Fix Most Cases

Start with the simplest checks. They rule out the “it’s installed but not being seen” cases before you dig into system settings.

  • Confirm your folder — In the project root, you should see package.json. If you’re one level above or inside a subfolder, scripts can break.
  • Install dependencies — Run npm install (or pnpm install, yarn) so node_modules exists and contains Vite.
  • Run the script, not the binary — Prefer npm run dev because npm automatically wires local binaries from node_modules/.bin.
  • Restart your terminal — PATH edits and new installs often won’t show up in an already-open shell window.
  • Check the script name — In package.json, your dev script should be something like "dev": "vite".

If those steps didn’t clear it, don’t guess. Narrow it down with two quick commands that tell you whether Vite exists locally.

  1. List installed Vite — Run npm ls vite in your project folder. If it shows “(empty)”, Vite isn’t installed in this project.
  2. Check the local bin — Run node -p "require('path').join(process.cwd(),'node_modules','.bin')" and confirm that folder exists.

Fix Vite In A Project

Most people hit this error right after cloning a repo or after deleting node_modules to reset things. Vite is usually meant to be a project dependency, not a tool you install once and use everywhere.

Install Vite The Right Way For Existing Projects

  1. Install the dependency — Run npm i -D vite (or the equivalent in your package manager).
  2. Set the scripts — In package.json, set "dev": "vite", "build": "vite build", and "preview": "vite preview".
  3. Start the dev server — Run npm run dev and keep using scripts instead of typing vite by hand.

Spot The Local Binary Without Guessing

If you want proof that Vite is installed where your project expects it, look for the bin shim inside node_modules/.bin. That folder is created during install and is what npm run uses.

  • List the bin shims — On Windows run dir node_modules\\.bin. On macOS/Linux run ls node_modules/.bin.
  • Look for vite — You should see a vite file or a Windows shim like vite.cmd.
  • Run it through npm exec — Try npm exec vite -- --version to run the local binary without relying on a global install.

If you scaffolded a fresh app, stick with the current official command. Vite’s docs recommend creating a new project with npm create vite@latest. You can see the current getting-started steps on the Vite site.

Vite getting started documentation

When You Must Run Vite Directly

Sometimes you’re in a scratch folder or testing a config and you want a one-off run. In that case, run Vite through a runner that can reach local binaries.

  • Use npx — Run npx vite from the project root. It will look for the local package first.
  • Use pnpm dlx — Run pnpm dlx vite for a temporary run without a global install.
  • Use yarn dlx — Run yarn dlx vite if you’re on modern Yarn.

Vite Is Not Recognized As An Internal Or External Command

This section is for the case where you installed Vite globally or you’re trying to run vite as a standalone command and your system still can’t find it.

Find Where npm Puts Global Commands

npm can print the exact folder where it installs global executables. Once you know that folder, you can check whether it’s on PATH.

  1. Show the global bin path — Run npm bin -g. On older npm versions this prints the global executable folder.
  2. Show the global prefix — Run npm prefix -g. On Windows, the bin folder often sits under your roaming profile.
  3. See what your shell sees — On Windows, run where vite. On macOS/Linux, run which vite.

If where vite prints nothing, the command isn’t on PATH. If it prints a path that points at an older Node install, you’re running the wrong npm instance.

Add The Correct Folder To PATH On Windows

On Windows, global npm commands usually live in a folder under your user profile. The exact location varies, so use the output from npm bin -g or npm prefix -g instead of copying a path from a random post.

  1. Open the PATH editor — Start Menu search “Edit the system PATH”, then open the user Path list.
  2. Add the npm bin folder — Paste the folder printed by npm bin -g (or the right bin folder under the prefix).
  3. Restart terminals — Close Command Prompt, PowerShell, and your IDE terminal tabs, then reopen them.
  4. Verify the command — Run where vite and confirm it returns a vite.cmd path.

Path edits only apply to new shell sessions. If you keep a terminal open all day, you can get stuck in a session that can’t see new commands.

Vite Not Recognized Error In Windows Terminals

Windows adds a few extra twists: multiple Node installs, multiple shells, and file association rules. Work through these in order and you’ll usually find the mismatch.

Check For Two Node Installs

  1. Print Node and npm locations — Run where node and where npm.
  2. Check versions — Run node -v and npm -v and confirm they match what you expect.
  3. Remove the stray install — Uninstall the older Node from Apps, then reinstall one clean copy from the official Node site.

A common trap is installing Node with one tool, then installing it again later with a second tool. Your PATH can end up pointing at one copy while npm writes global commands into the other copy’s folders.

Check Your Node Version Against Vite

Newer Vite releases require newer Node. If your Node version is too old, installs can fail and the vite command may never get created. Current Vite docs list Node 20.19+ or 22.12+ as the supported ranges.

  1. Print your Node version — Run node -v.
  2. Upgrade if needed — Install a Node LTS build, then reopen your terminal.
  3. Reinstall dependencies — Run npm install again so Vite is installed under the new Node.

Vite supported Node versions

PowerShell Script Policy Gotchas

In PowerShell, global commands can be exposed as .ps1 files. If script execution is blocked, a command may exist but still fail to run.

  • Test with cmd.exe — Open Command Prompt and run vite --version to see if it works there.
  • Use the .cmd shim — If vite.cmd exists, calling it from Command Prompt often works even when PowerShell is locked down.
  • Run via npm scriptsnpm run dev stays the least fragile route across shells.

Clean Reinstall When Nothing Works

If you’ve tried local install checks, PATH fixes, and you still see the error, do a clean reset. This clears out lockfile conflicts, broken caches, and half-installed packages.

  1. Close running dev servers — Stop any Node processes that might be locking files on Windows.
  2. Remove install artifacts — Delete node_modules and your lockfile (package-lock.json, pnpm-lock.yaml, or yarn.lock).
  3. Clear package cache — Run npm cache verify or npm cache clean --force if verify reports issues.
  4. Reinstall — Run npm install and wait for it to finish without errors.
  5. Run the dev script — Run npm run dev from the project root.

If your project uses pnpm, stick to pnpm for installs and scripts. Mixing package managers can leave node_modules in a state that looks installed but misses bin shims.

pnpm installation and troubleshooting

Keep It From Coming Back

Once you fix it, you can avoid seeing it again with a few small habits that keep your tools predictable across machines.

  • Prefer project scripts — Use npm run dev and npm run build so your project pins the Vite version it needs.
  • Pin Node with a version file — Add .nvmrc or set an engines field so teammates use the same Node major.
  • Document the setup — Add a short README section that lists install and run commands, plus the Node version.
  • Reopen terminals after installs — Make it a reflex after you install global tools or update PATH.

Make Your Scripts Self-Describing

A small script tweak can make this error easier to read when it pops up on a fresh machine. Add a precheck that prints versions.

  • Add a predev script — Set "predev": "node -v && npm -v" so the versions print each run.
  • Keep installs consistent — Use one package manager per repo and commit its lockfile.
  • Use create-vite for new appsnpm create vite@latest pulls the current scaffolder from npm.

If you’re still seeing “vite is not recognized as an internal or external command” after these steps, the fastest way to debug is to compare what where node, where npm, and where vite return in the same terminal window. That trio usually shows the mismatch in one glance.

Once the command resolves, your Vite app should start cleanly and you can get back to coding instead of wrestling with your shell.