The error, verbatim
Jump to the fix ↓> vite build
sh: 1: vite: not found
The fix that worked
Install the dev dependencies too; vite is a devDependency:
npm ci --include=devNot it? Every cause, tested ↓Tested on
- Vite
- 8.3.8
- Node / npm
- 24.22.3 / 11.19.1
- OS
- GitHub Actions ubuntu-latest (sh is dash) and macos-latest (arm64), November 22, 2026
Contents
npm run build runs vite build in a shell, and that shell looks for vite in node_modules/.bin, which npm puts on the PATH for scripts. If the file isn’t there, the shell prints its own “not found” message and npm exits with code 127. Vite itself never started.
On Windows the same problem reads 'vite' is not recognized as an internal or external command; that has its own post. This one is Linux, macOS, CI and Docker. I ran each cause on GitHub Actions, on Ubuntu and on macOS (Docker on Ubuntu only), with Vite 8.3.8.
The message depends on the shell
| Where | Message |
|---|---|
npm run build on Ubuntu (/bin/sh is dash) |
sh: 1: vite: not found |
npm run build on macOS |
sh: vite: command not found |
vite build in a bash script |
vite-command-not-found/ci.sh: line 15: vite: command not found |
All three mean the same thing: no vite on the PATH. Exit code 127 in each. (Typed at an interactive bash prompt the start reads bash: instead of the script name; that form was not part of the run.)
Which cause is yours
| What you did | Result | What fixed it |
|---|---|---|
| ran the build without installing | not found | npm ci |
NODE_ENV=production npm ci (common in Dockerfiles and CI) |
not found | npm ci --include=dev |
npm ci --omit=dev |
not found | plain npm ci (the control run) |
omit=dev in .npmrc |
not found | npm ci --include=dev |
typed vite build in the terminal |
not found | npx vite build, or npm run build |
node_modules/.bin deleted or not copied |
not found | npm rebuild |
| Docker bind mount over the app folder | not found | an anonymous volume for node_modules |
vite.js lost its execute bit |
Permission denied |
chmod +x node_modules/vite/bin/vite.js, or a clean npm ci |
Vite is normally a devDependency, as it was in the test project, so any install that skips dev dependencies leaves no vite behind. npm ci then says up to date and exits 0, which looks fine.
Production installs skip Vite
With NODE_ENV=production, npm treats omit as dev, so devDependencies are not installed. --omit=dev and omit=dev in .npmrc do the same. In my runs all three installs exited 0, and the build then failed with vite: not found (vite: command not found on macOS).
--include=dev overrides all three. It fixed the NODE_ENV=production and .npmrc cases on both systems:
NODE_ENV=production npm ci --include=dev
npm run buildIn a Dockerfile, set NODE_ENV=production after the build step, or build in one stage and copy only dist into the final image (not tested here).
Typed in the terminal
vite isn’t on your shell’s PATH, only on the one npm builds for scripts. Typed directly, vite build failed in bash and in sh. npx vite build, ./node_modules/.bin/vite build and npm run build all built.
Docker: the bind mount hides node_modules
docker run -v $PWD:/app mounts your folder over /app, including over the node_modules the image installed. If your folder has no node_modules, the container has none either. The image alone built; with the bind mount it failed with sh: 1: vite: not found.
Add an anonymous volume for node_modules, so the image’s copy shows through:
docker run --rm -v "$PWD":/app -v /app/node_modules my-imagenode_modules/.bin missing
If node_modules/.bin is deleted, or a copy step skips it, the package is there but the link isn’t. npm rebuild recreated the links and the build passed, on both systems.
Permission denied: the execute bit
A different message means a different problem: the link is there, but the file it points to, node_modules/vite/bin/vite.js, can’t be executed. I removed its execute bit to get this message, the way a copy or unpack that drops file modes would. A node_modules installed with sudo and owned by root is another reported cause; that one was not tested here.
| Where | Message | Exit code |
|---|---|---|
| Ubuntu (dash) | sh: 1: vite: Permission denied |
127 |
| macOS | sh: /…/node_modules/.bin/vite: Permission denied |
126 |
Restore the bit, or reinstall:
chmod +x node_modules/vite/bin/vite.js
# or
rm -rf node_modules && npm ciHow this was tested
GitHub Actions, ubuntu-latest (x86_64, /bin/sh is dash) and macos-latest (arm64), Node 24.22.3, npm 11.19.1, Vite 8.3.8, on November 22, 2026. Each case started from a fresh copy of one minimal Vite project (vite as a devDependency, "build": "vite build") and its lockfile. The output files keep the key lines of each command (filtered with grep) and every exit code. The Docker case ran on Ubuntu only. Yarn, pnpm and Bun were not tested. The script, the workflow and the full output of both runs (45042966654, and 45043227494 for the chmod +x and reinstall steps) are in nk-repro/vite-command-not-found.
— N.K., end of entry No.108