ENOENT node filesystem ai_generated true

Error: ENOENT: no such file or directory, open 'X'

ID: node/enoent-no-such-file

Also available as: JSON · Markdown
75%Fix Rate
80%Confidence
31Evidence
2015-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
20 active
20 active

Root Cause

ENOENT on macOS x64 is most commonly caused by missing files after incomplete npm installs, broken symlinks, or path assumptions that break when moving between case-insensitive HFS+ (default) and case-sensitive APFS volumes. Since macOS is case-insensitive by default, this error less often stems from case mismatches and more often from genuinely missing files or stale symlinks.

generic

Workarounds

  1. 70% success Verify the file path exists and check for broken symlinks
    Extract the path from the error message. Run 'ls -la <path>' and 'file <path>' to check if the target exists or is a broken symlink. If a symlink, recreate it with 'ln -s <real_target> <link_name>'.

    Sources: https://nodejs.org/api/fs.html#fsaccesspath-mode-callback

  2. 65% success Delete node_modules and package-lock.json, then reinstall
    rm -rf node_modules package-lock.json && npm install

    Sources: https://nodejs.org/api/errors.html#common-system-errors

  3. 50% success Check for case-sensitive volume if using APFS case-sensitive format
    Run 'diskutil info / | grep "File System Personality"' to check if the volume is case-sensitive. If so, audit file imports for case mismatches using 'find . -name "*.js" | xargs grep -n require'.

    Sources: https://nodejs.org/api/fs.html#file-system

Dead Ends

Common approaches that don't work:

  1. Running npm cache clean --force 95% fail

    ENOENT indicates a missing filesystem path, not npm cache corruption. Clearing the cache does not create missing files, fix broken symlinks, or correct path references in code.

  2. Reinstalling Xcode Command Line Tools 90% fail

    Unless the ENOENT involves a native module that requires compilation tools, reinstalling Xcode CLT has no effect on missing file paths. This conflates build errors with path resolution errors.

Error Chain

Frequently confused with: