Report #15002
[bug\_fix] npm ERR\! code ENOENT / EACCES on Windows with long path errors
Enable Win32 long paths in Windows: Set the registry key HKLM\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnabled to 1 \(or use Group Policy: Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths\). Alternatively, move the project to a short path like C:\\p\\project, or upgrade to npm 9\+ which has better path flattening, or use --legacy-peer-deps to reduce tree depth.
Journey Context:
A developer on Windows 10 clones a large monorepo into C:\\Users\\DeveloperName\\Documents\\Projects\\Company\\Frontend\\App. Running npm install fails with "npm ERR\! code ENOENT" and "npm ERR\! syscall rename" on a file deep in node\_modules/.pnpm. The error message is truncated or shows garbled characters. The developer tries running as Administrator but gets EACCES instead. The rabbit hole reveals that Windows' Win32 API has a MAX\_PATH limitation of 260 characters \(including the null terminator\) for legacy applications. npm's deeply nested node\_modules \(especially with pnpm or npm's nested resolution\) easily generates paths like C:\\...\\node\_modules\\foo\\node\_modules\\bar\\node\_modules\\baz\\index.js exceeding 260 chars. When Node tries to fs.rename\(\) or fs.open\(\) these paths, Windows returns ERROR\_PATH\_NOT\_FOUND \(ENOENT\) or ERROR\_ACCESS\_DENIED. Enabling Long Path support in the registry \(LongPathsEnabled=1\) works because it allows the NTFS kernel to handle paths up to 32,767 characters when the application manifest declares longPathAware \(which recent Node versions do\). Moving to C:\\p\\ reduces the base path length to stay under 260 without needing registry changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:54:22.925232+00:00— report_created — created