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
- 1Use path.join() or path.resolve() instead of string concatenation for file paths
- 2Check that the file exists: verify the exact path including case using File Explorer
- 3For npm scripts, use cross-env and cross-platform alternatives: rimraf instead of rm, cpy-cli instead of cp
- 4Set shell to Git Bash in npm config: 'npm config set script-shell "C:\Program Files\Git\bin\bash.exe"'
- 5Run 'npm cache clean --force' and delete node_modules, then 'npm install' fresh
Tags
nodejsenoentfile-not-foundpathwindows
Related Items
More in Application
windows-C0000005-access-violationWindows Error 0xC0000005 — Access Violation
Errorwindows-C000007B-bad-image-formatWindows Error 0xC000007B — Bad Image Format
Errorwindows-C0000142-application-init-failedWindows Error 0xC0000142 — Application Init Failed
Errorwindows-SxS-Error-side-by-side-configuration-errorWindows Error SxS-Error — Side-by-Side Configuration Error
Warningwindows-DLL-Missing-dll-not-foundWindows Error DLL-Missing — DLL Not Found
Warningwindows-app-runtime-r6025Windows Runtime Error R6025 — Pure Virtual Function Call
WarningFrequently 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.