Lingua-e
JavaScript

What is a spawn ENOENT?

← Errors

Node.js throws a spawn ENOENT error when child_process.spawn() cannot find the executable specified. This is the process spawning equivalent of ENOENT for files: the binary does not exist at any location in the system PATH.

Why it happens

  • The executable name is wrong or uses a different name on this OS (python vs python3).
  • The tool is not installed on the system.
  • The tool is installed but not in the PATH environment variable.
  • On Windows, missing the .exe extension or using Unix-style paths.

Examples

JavaScript

Code that triggers the error

const { spawn } = require("child_process");
const proc = spawn("python", ["script.py"]);
proc.on("error", console.error);

Error output

Error: spawn python ENOENT
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn python',
    path: 'python'

How to fix it

Verify the executable exists with which <command> (Unix) or where <command> (Windows). Use the full absolute path to the executable. Ensure the required tool is installed as part of your CI/CD setup. Use process.env.PATH to debug what directories are searched.

Fixed code

const { spawn } = require("child_process");
// Use 'python3' on systems where python3 is the correct binary
const proc = spawn("python3", ["script.py"]);
proc.on("error", (err) => {
  if (err.code === "ENOENT") {
    console.error("python3 not found in PATH");
  }
});

Related errors

Ready to practice your English at work?

Lingua-e has interactive exercises built around real developer conversations: standups, code reviews, retrospectives, and more. Practice until it comes naturally.

Try Lingua-e for free