Skip to content
Nilay Kabariya

Entry No.108·Fixes··4 min read

sh: vite: command not found on Linux, macOS, CI and Docker

sh: vite: command not found in CI, Docker or a Linux shell: six causes tested on Ubuntu and macOS, the exact message each one prints, and which fix worked.

by Nilay#vite#npm#node#docker#linuxFIXED

The error, verbatim

Jump to the fix ↓
> vite build

sh: 1: vite: not found
✓ Reproduced on GitHub Actions ubuntu-latest (sh is dash) and macos-latest (arm64), November 22,

The fix that worked

Install the dev dependencies too; vite is a devDependency:

npm ci --include=dev
Not 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

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 build

In 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-image

node_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 ci

How 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

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.110

    Cannot find module @rollup/rollup-linux-x64-gnu: what causes it

    Rollup blames an npm bug and says to delete your lockfile. On npm 11 that wasn't it: five setups that gave the error on Linux and Alpine, and the fix for each.

    > Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.

    FIXED3 min
  2. No.093

    Fix: bigint Failed to load bindings, pure JS will be used

    bigint: Failed to load bindings, pure JS will be used. Why npm 12 shows it on every install, whether it matters, and how to get the native build back.

    > bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)

    FIXED3 minWindows
  3. No.090

    Node 26 error: libatomic.so.1 cannot open shared object file

    node: error while loading shared libraries: libatomic.so.1 after moving to Node 26? Tested on 9 Linux images, Docker and nvm: what each distro is missing.

    > node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

    FIXED4 min

tip: paste the exact error text