# 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.

Source: https://livops.dev/en/guides/error-vite-permission-denied

By Livops team, the people who build and run Livops. Updated 4 December 2026.

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`):

```text
> my-app@0.0.0 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](https://livops.dev/en/guides/error-command-not-found-vite) |

### 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:

```sh
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:

```text
# .dockerignore
node_modules
```

```dockerfile
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`.

```sh
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](https://livops.dev/en/guides/error-npm-ci-lockfile-out-of-sync).

To check the result, look at the file the shell will run. `-L` follows the link to the real file:

```sh
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

```sh
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:

```sh
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 `install` and `build` in `livops.json`, which are applied on every deploy. See [Frameworks and livops.json](https://livops.dev/en/docs/frameworks).
- **An uploaded folder never brings node_modules.** When you upload a folder or a `.zip`, `node_modules` is dropped automatically, along with `.git`, `.next` and other build leftovers; see [Ways to deploy](https://livops.dev/en/docs/deploy). If an upload is rejected as too big, it is usually `node_modules` that 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 `.dockerignore` and 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](https://livops.dev/en/docs/error-build).

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](https://livops.dev/en/docs/pricing).

When the log says `not found` instead, the tool was never installed: see [sh: vite: not found](https://livops.dev/en/guides/error-command-not-found-vite). For a native module from another machine, the same mistake looks like [invalid ELF header](https://livops.dev/en/guides/error-bcrypt-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

1. [POSIX.1-2024 — Shell Command Language, 2.8.2 Exit Status for Commands](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html). Checked 4 December 2026.
2. [GNU Bash manual — Exit Status](https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html). Checked 4 December 2026.
3. [Linux man-pages 6.19 — execve(2)](https://man7.org/linux/man-pages/man2/execve.2.html). Checked 4 December 2026.
4. [npm Docs — npm run](https://docs.npmjs.com/cli/v11/commands/npm-run/). Checked 4 December 2026.
5. [npm Docs — folders, executables](https://docs.npmjs.com/cli/v11/configuring-npm/folders/). Checked 4 December 2026.
6. [npm Docs — package.json, bin](https://docs.npmjs.com/cli/v11/configuring-npm/package-json/). Checked 4 December 2026.
7. [bin-links v7.0.1 source — lib/link-bin.js](https://github.com/npm/bin-links/blob/v7.0.1/lib/link-bin.js). Checked 4 December 2026.
8. [bin-links v7.0.1 source — lib/fix-bin.js](https://github.com/npm/bin-links/blob/v7.0.1/lib/fix-bin.js). Checked 4 December 2026.
9. [cmd-shim v9.0.2 source — lib/index.js](https://github.com/npm/cmd-shim/blob/v9.0.2/lib/index.js). Checked 4 December 2026.
10. [Node.js docs — File system, file modes](https://nodejs.org/api/fs.html). Checked 4 December 2026.
11. [Git docs — git-config, core.fileMode and core.symlinks](https://git-scm.com/docs/git-config). Checked 4 December 2026.
12. [PKWARE — .ZIP File Format Specification (APPNOTE 6.3.10)](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT). Checked 4 December 2026.
13. [npm Docs — npm ci](https://docs.npmjs.com/cli/v11/commands/npm-ci/). Checked 4 December 2026.
14. [Docker docs — Build context, .dockerignore files](https://docs.docker.com/build/concepts/context/). Checked 4 December 2026.
15. [GNU Coreutils manual — chmod invocation](https://www.gnu.org/software/coreutils/manual/html_node/chmod-invocation.html). Checked 4 December 2026.
16. [npm Docs — npm exec](https://docs.npmjs.com/cli/v11/commands/npm-exec/). Checked 4 December 2026.
17. [Vite v8.4.1 source — packages/vite/package.json](https://github.com/vitejs/vite/blob/v8.4.1/packages/vite/package.json). Checked 4 December 2026.
18. [unpkg — next@16.5.0 package.json](https://unpkg.com/next@16.5.0/package.json). Checked 4 December 2026.
19. [unpkg — typescript@7.0.2 package.json](https://unpkg.com/typescript@7.0.2/package.json). Checked 4 December 2026.
20. [unpkg — react-scripts@5.0.1 package.json](https://unpkg.com/react-scripts@5.0.1/package.json). Checked 4 December 2026.
21. [unpkg — @nestjs/cli@12.0.15 package.json](https://unpkg.com/@nestjs/cli@12.0.15/package.json). Checked 4 December 2026.
