diff --git a/lib/fs.js b/lib/fs.js index 89c005375f450e..dba9049faec111 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -228,11 +228,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) {