Error Codes Wiki

Node.js ENOENT Error on Windows — File or Directory Not Found

Warningapplication

Overview

Fix Node.js ENOENT (Error NO ENTry) errors on Windows caused by missing files, incorrect paths, backslash issues, and case sensitivity mismatches.

Key Details

  • ENOENT stands for 'Error NO ENTry' — the requested file or directory does not exist at the specified path
  • Windows uses backslashes (\) while Node.js and Unix use forward slashes (/)
  • Path.join() and path.resolve() handle OS-specific path separators automatically
  • Case sensitivity differences: Windows is case-insensitive but Git and Node.js modules may expect exact case
  • Common in npm install when postinstall scripts reference files with hard-coded Unix paths

Common Causes

  • Hard-coded forward-slash paths that do not resolve correctly on Windows
  • File referenced in code was deleted, moved, or never created
  • Case mismatch: require('./MyFile') when the actual file is myfile.js
  • npm postinstall or build scripts using Unix commands (cp, rm) not available on Windows

Steps

  1. 1Use path.join() or path.resolve() instead of string concatenation for file paths
  2. 2Check that the file exists: verify the exact path including case using File Explorer
  3. 3For npm scripts, use cross-env and cross-platform alternatives: rimraf instead of rm, cpy-cli instead of cp
  4. 4Set shell to Git Bash in npm config: 'npm config set script-shell "C:\Program Files\Git\bin\bash.exe"'
  5. 5Run 'npm cache clean --force' and delete node_modules, then 'npm install' fresh

Tags

nodejsenoentfile-not-foundpathwindows

Related Items

More in Application

Frequently Asked Questions

Mac uses forward slashes and is case-insensitive (by default). Windows uses backslashes and has different path resolution. Use path.join() for cross-platform compatibility.