diff --git a/lib/fs.js b/lib/fs.js index b92aa435bab..d794f910656 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1227,8 +1227,17 @@ fs.realpathSync = function realpathSync(p, cache) { // some known symbolic link. no need to stat again. resolvedLink = cache[base]; } else { - var stat = fs.lstatSync(base); - if (!stat.isSymbolicLink()) { + var stat = null; + try { + stat = fs.lstatSync(base); + } catch (e) { + // Windows throws an exception if NTFS permissions are missing + if (!isWindows || e.code != 'EPERM') { + throw e; + } + } + + if (stat == null || !stat.isSymbolicLink()) { knownHard[base] = true; if (cache) cache[base] = base; continue;