ENOENT

noun

say it: “ee-NOH-ent” /iˈnoʊˌɛnt/

The error code Node reports when a program tries to use a file or folder that isn't there.

What does the error code ENOENT mean?

ENOENT is the error code Node gives when there's no file or folder at the path you used; read it as "error: no entry". Catch it to answer clearly, such as starting with an empty list when a save file doesn't exist yet.

try {
  const text = await readFile("orders.json", "utf8");
} catch (error) {
  if (error.code === "ENOENT") console.log("No orders yet.");
  else throw error;
}

In a sentence

  • “Check error.code for ENOENT and start from an empty list instead of crashing.”
  • “The first run failed with ENOENT because the training log file hadn't been made yet.”

Level: Apprentice · More Node.js terms at this level

Updated