diff --git a/lib/fs.js b/lib/fs.js index 9e74beee285f2d..56421924fd287a 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -221,11 +221,14 @@ Object.defineProperty(exists, internalUtil.promisify.custom, { // TODO(joyeecheung): deprecate the never-throw-on-invalid-arguments behavior function existsSync(path) { try { - fs.accessSync(path, F_OK); - return true; + path = toPathIfFileURL(path); + validatePath(path); } catch (e) { return false; } + const ctx = { path }; + binding.access(pathModule.toNamespacedPath(path), F_OK, undefined, ctx); + return ctx.errno === undefined; } function readFileAfterOpen(err, fd) {