diff --git a/lib/module.js b/lib/module.js index 1b9c2413b7..77675fcd98 100644 --- a/lib/module.js +++ b/lib/module.js @@ -165,10 +165,11 @@ Module._findPath = function(request, paths, isMain) { return false; } - const cacheKey = JSON.stringify({request: request, paths: paths}); - if (Module._pathCache[cacheKey]) { - return Module._pathCache[cacheKey]; - } + var cacheKey = request + '\x00' + + (paths.length === 1 ? paths[0] : paths.join('\x00')); + var entry = Module._pathCache[cacheKey]; + if (entry) + return entry; var exts; var trailingSlash = request.length > 0 &&