localhost:5173 / vite-not-found
vite: command not found / 'vite' is not recognized
The shell cannot find the vite binary: either the vite package is not in node_modules of this project, or it is installed and you typed vite outside an npm script, where node_modules/.bin is not on the PATH.
sh: vite: command not found # Windows (cmd.exe) 'vite' is not recognized as an internal or external command, operable program or batch file.
Which message does your shell print?
The cause is the same in every shell. Only the wording changes, depending on which shell ran the command. npm runs scripts with /bin/sh on Unix-like systems and with cmd.exe on Windows, so the message from npm run dev comes from that shell, not from your terminal. The exit code is 127 in every Unix case below. Reproduced on 5 October 2026 with Vite 8.3.2 and npm 11.17.0.
- macOS, npm run dev: sh: vite: command not found
- macOS, vite typed in zsh: zsh: command not found: vite
- bash: bash: vite: command not found
- Debian or Ubuntu container (node:24-slim, sh is dash): sh: 1: vite: not found
- Alpine container (node:24-alpine): sh: vite: not found
- Windows, cmd.exe: 'vite' is not recognized as an internal or external command, operable program or batch file. (Not reproduced here; we have no Windows machine.)
Vite is installed, but typing vite still fails
This is expected. A scaffolded Vite project lists vite under devDependencies, so npm installs it into node_modules/.bin of the project, not into a directory on your PATH. npm run adds node_modules/.bin to the PATH, but only for the script it runs. Reproduced: with vite installed in the project, npm run dev starts the server on 5173, and the same vite typed straight into zsh exits with 127.
$ npm run dev ➜ Local: http://localhost:5173/ $ vite zsh: command not found: vite # both of these use the project's own copy $ npx vite $ ./node_modules/.bin/vite
npm run dev fails: the package is not in node_modules
If the error comes from npm run dev, the binary is really missing in this project. The usual reasons are a fresh clone (node_modules is not in the repository), an interrupted install, or an install that ran in a different directory. The fix is the install in the directory where package.json is.
$ ls node_modules/.bin/vite ls: node_modules/.bin/vite: No such file or directory # in the folder that contains package.json $ npm install $ npm run dev
The install ran, but skipped devDependencies
vite is a devDependency, and npm leaves devDependencies out when NODE_ENV is production or when you pass --omit=dev. The install finishes without an error, and npm run dev then fails exactly as if nothing were installed. We reproduced both on macOS and NODE_ENV=production in a node:24-slim container: no node_modules/.bin/vite, exit 127. This is the most common cause in Dockerfiles and CI, where NODE_ENV=production is often set globally.
$ NODE_ENV=production npm install $ npm run dev sh: 1: vite: not found # install devDependencies anyway $ npm install --include=dev
Why npx vite is not a safe workaround
npx first looks in the project. If vite is not there, it downloads the package into the npm cache and runs that copy. Without a terminal attached, for example in a script or a container, it did not ask: in an empty folder, npx vite printed a warning, installed [email protected] (the latest version on 5 October 2026) and started it. Your project may pin an older major with different server defaults. Install the project dependencies instead of letting npx pick a version for you.
$ npx vite --version npm warn exec The following package was not found and will be installed: [email protected] vite/8.3.2 darwin-arm64 node-v24.19.0
Should you install vite globally?
It makes vite available in the terminal, but it is not what the Vite docs suggest. They say to use the vite binary in npm scripts or to run it with npx vite. A global install runs one version for all your projects, whatever version each project expects. The scripts in package.json already run the right one.
Read the error in order
- Error from npm run dev: the package is missing in this project. Run npm install where package.json is.
- Error only when you type vite: nothing is broken. Use npm run dev or npx vite.
- Error after an install in CI or Docker: check NODE_ENV and --omit=dev.
- No error, but no address block either: the binary was found and the problem is later in the start. See the startup sequence.
# faq
Questions
Why does vite say command not found when it is installed?
Because it is installed locally in node_modules/.bin, which is only on the PATH inside npm scripts. Run npm run dev or npx vite instead of vite.
How do I fix 'vite' is not recognized as an internal or external command on Windows?
Run npm install in the folder that contains package.json, then start the server with npm run dev. The message means cmd.exe found no vite in node_modules/.bin or on the PATH.
What does sh: 1: vite: not found mean in Docker?
It is the dash shell of Debian-based images saying that vite is not in node_modules. Most often the install skipped devDependencies because NODE_ENV=production is set.
Should I run npm install -g vite?
Not to fix this. It runs one global version for every project. The Vite docs use the vite binary in npm scripts or npx vite.
What exit code does vite: command not found return?
In every Unix shell tested here (sh on macOS, zsh, bash, dash, Alpine sh) it is 127, the shell code for a command that was not found.
# next
Related
# sources
- Vite — Getting Started: Command Line Interface
- Vite source v8.3.2 — create-vite template-vanilla/package.json (vite in devDependencies)
- npm — npm run (node_modules/.bin on the PATH, script shell)
- npm — npm install (devDependencies and NODE_ENV=production)
- npm — npx (packages outside the project go to the npm cache)
Checked against the Vite documentation on 2026-10-05.