sh: 1: vite: Permission denied (also next, tsc, react-scripts, nest): exit code 126 and the fix
sh: 1: vite: Permission denied, with exit code 126, means the shell found node_modules/.bin/vite but was not allowed to run it: the file has no execute permission. Almost always node_modules was not installed on the machine that builds, but committed, zipped or copied from another one, often a Windows PC, and the execute bit was lost on the way. Keep node_modules out of git, uploads and images, and run a clean npm ci where the build runs. chmod +x is only a stopgap.
By Livops team, the people who build and run LivopsUpdated
As it appears in a build log on a Debian or Ubuntu based image (the wording varies by shell; some print the full path to node_modules/.bin/vite):
> [email protected] build
> vite build
sh: 1: vite: Permission denied
or the same with next, tsc, react-scripts or nest. The build then stops with exit code 126. This page explains what the shell is telling you, why the file lost its permission, the fix for each cause, a stopgap for when you need the build now, and how the install runs on Livops.
What does the error mean?
Found, but not executable: 126, not 127
The shell decides the exit code. POSIX says: a command that is not found gets exit status 127; a command that is found but is not an executable utility gets 126[1]. Bash says the same[2]. So Permission denied with 126 means the opposite of the better-known error: the file is there, and the system refused to run it. When the system refuses, the reason is one of these: execute permission is denied for the file, or for the script’s interpreter, the file is not a regular file, or the filesystem is mounted noexec[3].
| The log says | Exit code | Meaning | Page |
|---|---|---|---|
vite: Permission denied |
126 | node_modules/.bin/vite exists, without execute permission |
this page |
vite: not found |
127 | There is no node_modules/.bin/vite in that folder |
sh: vite: not found |
Where the vite file comes from
npm run hands the script to /bin/sh on Unix-like systems and adds node_modules/.bin to its PATH[4]. That folder is filled by the install: npm links each package’s commands into ./node_modules/.bin[5], following the bin field of the package’s package.json[6]. For Vite that field maps vite to bin/vite.js[17].
On Linux and macOS, .bin/vite is a symlink to ../vite/bin/vite.js[5], and when npm creates the link it also makes the target file executable[7][8]. On Windows, npm writes three files instead: vite, a #!/bin/sh script, plus vite.cmd and vite.ps1[9]. So node_modules/.bin is only correct on the kind of machine that ran the install, and only as long as the execute bits survive.
Causes, most common first
1. node_modules is committed to the repository
The server clones the repository, and with it a node_modules made on a developer’s machine. From Windows the problem is built in: Windows does not keep Unix execute permissions, Node’s own chmod there can change only the write permission[10], and Git on such a filesystem is set up with core.fileMode off, which tells it not to honor the executable bit[11]. A Windows checkout can also turn symlinks into small plain files that contain the link’s text[11]. Either way, the Linux build gets .bin/vite without its execute bit.
Fix: take node_modules out of the repository and keep it out:
git rm -r --cached node_modules
echo node_modules >> .gitignore
git commit -m "Stop committing node_modules"
2. A zip or a copy lost the execute bit
A .zip of the project with node_modules inside, sent to a server or a hosting panel. The zip format stores a file’s attributes in the format of the system that made the archive, MS-DOS or Unix among others[12], so whether the execute bit survives depends on the tool that zipped the folder and the one that unpacked it. The same goes for an FTP upload or a copy through a shared drive.
Fix: leave node_modules out of whatever you send, and install on the server. If a node_modules is already there, npm ci removes it before it installs[13], so nothing from the copy survives.
3. A Docker build copies node_modules from your machine
COPY . . without a .dockerignore sends your local node_modules into the image, on top of the one the image installed or instead of it. The image then runs whatever your machine’s .bin folder held, Windows shims included, not what its own install made. Fix: list node_modules in a .dockerignore at the root of the build context; Docker removes matching files from the context before it is sent to the builder[14]. Then install inside the image:
# .dockerignore
node_modules
FROM node:22-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
4. The folder is on a noexec filesystem
If node_modules sits on a filesystem mounted with noexec, nothing on it can be executed, whatever its permissions say[3]. This shows up when a CI job or a container builds in a mounted volume or a temporary folder that the administrator mounted that way. Fix: build in a folder on a normal filesystem, or run the tool through node as below, which only reads the file.
The fix: install where you build
All of the causes above share one fix: the machine that builds should create its own node_modules.
rm -rf node_modules
npm ci
npm run build
npm ci installs exactly what package-lock.json says and removes an existing node_modules first[13]; linking the commands makes them executable again[7][8]. If npm ci stops because package.json and the lockfile disagree, see npm ci: not in sync.
To check the result, look at the file the shell will run. -L follows the link to the real file:
ls -lL node_modules/.bin/vite
# -rwxr-xr-x ... node_modules/.bin/vite the x is what was missing
When you need the build now
chmod +x, a stopgap
chmod +x node_modules/.bin/*
For each symlink named on the command line, chmod changes the file it points to[15], so for the usual links this marks the real vite.js, next or tsc file executable, and a plain file, such as a shim made on Windows, is marked itself. The build passes, and the next copy of node_modules brings the problem back. Use it to unblock a deploy, then fix the cause.
Run the tool through node
node reads the file as a script, so the file does not need execute permission:
node node_modules/vite/bin/vite.js build
The path is the bin field of the tool’s package.json[6]:
| Command | Run instead |
|---|---|
vite build |
node node_modules/vite/bin/vite.js build[17] |
next build |
node node_modules/next/dist/bin/next build[18] |
tsc |
node node_modules/typescript/bin/tsc[19] |
react-scripts build |
node node_modules/react-scripts/bin/react-scripts.js build[20] |
nest build |
node node_modules/@nestjs/cli/bin/nest.js build[21] |
The paths are from the current versions of each package; check yours in node_modules/<package>/package.json if it is older.
npx vite build does not help with this error. npx puts the locally installed commands on the PATH[16], so it runs the same node_modules/.bin/vite and gets the same Permission denied.
On Livops
- Livops installs the dependencies itself. It detects the framework, Vite and Next.js among them, and from it the install and build commands. Change them under Settings → Install and Settings → Build, or with
installandbuildinlivops.json, which are applied on every deploy. See Frameworks and livops.json. - An uploaded folder never brings node_modules. When you upload a folder or a
.zip,node_modulesis dropped automatically, along with.git,.nextand other build leftovers; see Ways to deploy. If an upload is rejected as too big, it is usuallynode_modulesthat makes it so: remove it, since the dependencies are installed during the build. - Your own Dockerfile. If the repository has a
Dockerfile, it is used, and cause 3 depends on what it copies: add the.dockerignoreand install in the image. - Where the error shows. The build command ends with an error, the deploy stops as
build_failed, and the previous version keeps running. The build log shows the line, and next to the failed build the assistant’s button reads the log and explains what happened. See Build failed.
A static Vite site is free on Livops; an app with a server, such as a NestJS API, costs 39 credits a month. See Pricing.
When the log says not found instead, the tool was never installed: see sh: vite: not found. For a native module from another machine, the same mistake looks like invalid ELF header.
Questions
What does exit code 126 mean?
The shell found the command but could not execute it. POSIX shells use 126 for a command that was found but is not executable, and 127 for one that was not found at all. In npm run build, 126 almost always means the file in node_modules/.bin has no execute permission.
What is the difference between vite Permission denied and vite not found?
Permission denied, exit code 126, means node_modules/.bin/vite exists but cannot be run. Not found, exit code 127, means there is no such file: vite was never installed in that folder, often because devDependencies were skipped. The fixes are different, so read which one the log says.
Why does it work on my machine but not on the server?
On your machine npm installed the packages and made their command files executable. The server got a copy of that folder through git, a zip or a file copy, and the execute bit did not survive the trip. A copy made on Windows never had it, because Windows does not keep Unix execute permissions.
Is chmod +x node_modules/.bin/* a real fix?
It makes this build pass, but the cause stays: the next copy of node_modules brings the same problem back. The real fix is to stop shipping node_modules at all and let the build machine run its own clean npm ci, which links every command and makes it executable.
Will npx vite build work instead?
Not for this error. npx puts the same local node_modules/.bin on the PATH and runs the same file, so it fails with the same Permission denied. What does work is giving the file to Node yourself: node node_modules/vite/bin/vite.js build. Node only reads the file, so it does not need the execute bit.
Should I commit node_modules?
No. It is built for the machine that ran the install: its command links, the execute bits and any native binaries all depend on that machine. Commit package.json and package-lock.json, add node_modules to .gitignore, and install from the lockfile where the app is built.
Sources
- POSIX.1-2024 — Shell Command Language, 2.8.2 Exit Status for Commands (pubs.opengroup.org). Checked .
- GNU Bash manual — Exit Status (gnu.org). Checked .
- Linux man-pages 6.19 — execve(2) (man7.org). Checked .
- npm Docs — npm run (docs.npmjs.com). Checked .
- npm Docs — folders, executables (docs.npmjs.com). Checked .
- npm Docs — package.json, bin (docs.npmjs.com). Checked .
- bin-links v7.0.1 source — lib/link-bin.js (github.com). Checked .
- bin-links v7.0.1 source — lib/fix-bin.js (github.com). Checked .
- cmd-shim v9.0.2 source — lib/index.js (github.com). Checked .
- Node.js docs — File system, file modes (nodejs.org). Checked .
- Git docs — git-config, core.fileMode and core.symlinks (git-scm.com). Checked .
- PKWARE — .ZIP File Format Specification (APPNOTE 6.3.10) (pkware.cachefly.net). Checked .
- npm Docs — npm ci (docs.npmjs.com). Checked .
- Docker docs — Build context, .dockerignore files (docs.docker.com). Checked .
- GNU Coreutils manual — chmod invocation (gnu.org). Checked .
- npm Docs — npm exec (docs.npmjs.com). Checked .
- Vite v8.4.1 source — packages/vite/package.json (github.com). Checked .
- unpkg — [email protected] package.json (unpkg.com). Checked .
- unpkg — [email protected] package.json (unpkg.com). Checked .
- unpkg — [email protected] package.json (unpkg.com). Checked .
- unpkg — @nestjs/[email protected] package.json (unpkg.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Vite appRelated
- sh: vite: not found (also next, tsc) in npm run build: how to fix itsh: 1: vite: not found, sh: next: not found or tsc: not found during npm run build (exit code 127) means the shell found no such command in node_modules/.bin. Usually the install skipped devDependencies because NODE_ENV=production or --omit=dev, the install never ran in that folder, or the tool was only installed globally on your laptop. Install it into the project and make the build's install include dev dependencies.
- bcrypt_lib.node: invalid ELF header — why bcrypt fails in Docker and on Linuxinvalid ELF header, with code ERR_DLOPEN_FAILED, means Node on Linux tried to load a bcrypt binary that is not a Linux library: node_modules was installed on a Mac or Windows and then copied to the server, by a COPY . . without a .dockerignore or a committed node_modules folder. Keep node_modules out of the image and the repository and install inside Linux with npm ci, or switch to bcryptjs, which has no binary at all.
- npm ci can only install packages when your package.json and package-lock.json are in sync: how to fix itnpm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync (npm error code EUSAGE) means the committed lockfile no longer matches package.json: a dependency was added or changed without re-running npm install, or the lockfile was not committed. Run npm install locally, commit package.json and package-lock.json together, and npm ci passes.
- npm failed with return code 1 (npm ERR! code 1): how to fix the buildnpm failed with return code 1, or npm install exited with 1, is npm ERR! code 1 in newer npm: it only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- exec format error in Docker: the image was built for another CPUThe kernel refused to run the container's program because it is not an executable for this machine: almost always a binary or image built for arm64 (an Apple Silicon Mac) running on an amd64 server, or the reverse. Build for the server's platform with --platform linux/amd64, or as a multi-platform image; if the file is a script, give it a #! line.
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.