diff --git a/lib/async.js b/lib/async.js index 9642e5ac..59c7de42 100644 --- a/lib/async.js +++ b/lib/async.js @@ -5,7 +5,19 @@ var nodeModulesPaths = require('./node-modules-paths'); var normalizeOptions = require('./normalize-options'); var isCore = require('is-core-module'); -var realpathFS = fs.realpath && typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath; +function realpathFS(path, callback) { + if (typeof fs.realpath.native === 'function') { + fs.realpath.native(path, function (realpathErr, realPath) { + if (realpathErr && realpathErr.errno === -4068) { + fs.realpath(path, callback); + } else { + return callback(realpathErr, realPath); + } + }); + } else { + fs.realpath(path, callback); + } +} var defaultIsFile = function isFile(file, cb) { fs.stat(file, function (err, stat) { diff --git a/lib/sync.js b/lib/sync.js index a15e20fd..96a72dc8 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -5,7 +5,19 @@ var caller = require('./caller'); var nodeModulesPaths = require('./node-modules-paths'); var normalizeOptions = require('./normalize-options'); -var realpathFS = fs.realpathSync && typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync; +function realpathFS(path) { + if (typeof fs.realpathSync.native === 'function') { + try { + return fs.realpathSync.native(path); + } catch (realpathErr) { + if (!realpathErr || realpathErr.errno !== -4068) { + throw realpathErr; + } + } + } + + return fs.realpathSync(path); +} var defaultIsFile = function isFile(file) { try {