How to fix Error: spawn EACCES in Node.js

Node.jsBEGINNERHIGHUpdated Dec 9, 2025· 237 views

The spawn EACCES error occurs when Node.js attempts to spawn a child process but lacks execute permissions on the target executable. This commonly happens with binary files in node_modules or custom scripts that are missing the executable bit.

Quick fix

Fixes EACCES

ls -la /path/to/executable
  1. Identify the missing executable permission
  2. Add execute permission to the binary
  3. Verify the permission change
  4. Reinstall node_modules if needed
node.js — error
ls -la /path/to/executable
Error: spawn EACCES

What this error means

The EACCES error code stands for "Error Access" and indicates that the operating system denied permission to execute a file. When Node.js child_process.spawn() attempts to launch an executable, the kernel checks if the calling process has execute permissions on that file. If the executable bit is not set, the spawn call fails immediately with EACCES. This is different from file read/write permissions—the executable bit is a separate permission that indicates the file is meant to be executed as a program. Without this bit set, the operating system will not allow execution, regardless of other permissions.

Typical symptoms

  • Error: spawn EACCES appears in your console or logs
  • Child process spawn() calls fail at runtime
  • Package CLI commands fail (e.g., npm scripts that invoke binaries)
  • Build tools or test runners fail when trying to spawn subprocesses
  • The error occurs specifically on Linux/macOS (less common on Windows)
  • Manual execution of the same file works with sudo

Common causes

  1. The target executable file is missing the executable (x) permission bit on Linux/macOS
  2. Files extracted from archives or git without preserving execute permissions
  3. Binaries installed in node_modules that lost execute permissions during transfer/copy
  4. Custom shell scripts or executables created without proper chmod settings
  5. File permission issues after npm install or yarn install in certain environments
  6. WSL (Windows Subsystem for Linux) mounting issues with Windows NTFS filesystems

How to fix "Error: spawn EACCES"

1Identify the missing executable permission

Check if the target file has execute permissions using:

bash
ls -la /path/to/executable

Look for the 'x' flag in the permission string. For example:
- -rwxr-xr-x (good - executable)
- -rw-r--r-- (bad - missing executable bit)

2Add execute permission to the binary

Use chmod to add execute permissions:

bash
chmod +x /path/to/executable

For executables in node_modules (e.g., Next.js bin):

bash
chmod +x node_modules/.bin/next

Or recursively for all binaries in a package:

bash
chmod -R u+x node_modules/package-name/bin
3Verify the permission change

Confirm the executable bit is now set:

bash
ls -la /path/to/executable

The permission string should now include 'x', such as -rwxr-xr-x.

4Reinstall node_modules if needed

If the error affects multiple node_modules binaries, reinstall them:

bash
rm -rf node_modules package-lock.json
npm install

This ensures all binaries are installed with correct permissions. Alternatively, use:

bash
npm ci

which respects the lock file and is more reliable for CI environments.

5Test the spawn operation

Verify that the child process spawns successfully:

javascript
const { spawn } = require('child_process')

const child = spawn('./your-executable', ['arg1', 'arg2'])

child.on('error', (err) => {
  console.error('Spawn error:', err)
})

child.on('exit', (code) => {
  console.log('Process exited with code:', code)
})

If no error event fires, the spawn succeeded.

Advanced notes

WSL and NTFS mounting issues: If you're running Node.js in WSL and your project is on a Windows NTFS mount, file permissions behave differently. NTFS doesn't have Unix-style execute bits. To fix, move your project to the WSL filesystem (typically under /home/username) or use WSL-specific mount options.

Git and execute permissions: If you commit executables to git but they lose the execute bit when checked out, configure git to preserve permissions:

bash
git config core.filemode true
git update-index --chmod=+x scripts/your-script.sh

Docker and node_modules: When copying node_modules into a Docker image, execute permissions are preserved by default with COPY. However, if you manually install packages inside the container, ensure the Dockerfile runs npm install (not copying pre-built node_modules from your local machine).

CI/CD environments: In automated pipelines, always run npm ci instead of npm install to ensure deterministic builds. However, if you encounter EACCES in CI even with npm ci, explicitly add permissions in your build script before running child processes.

Frequently asked questions

What does "EACCES" mean?
The EACCES error code stands for "Error Access" and indicates that the operating system denied permission to execute a file. spawn() attempts to launch an executable, the kernel checks if the calling process has execute permissions on that file. If the executable bit is not set, the spawn call fails immediately with EACCES.
How do I fix "EACCES"?
The spawn EACCES error occurs when Node.js attempts to spawn a child process but lacks execute permissions on the target executable. This commonly happens with binary files in node_modules or custom scripts that are missing the executable bit.
What causes "EACCES"?
The target executable file is missing the executable (x) permission bit on Linux/macOS Files extracted from archives or git without preserving execute permissions Binaries installed in node_modules that lost execute permissions during transfer/copy
Is the "EACCES" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading