diff --git a/tools/isobuild/bundler.js b/tools/isobuild/bundler.js index f84c95b8c3..5493510c5b 100644 --- a/tools/isobuild/bundler.js +++ b/tools/isobuild/bundler.js @@ -482,8 +482,9 @@ export class NodeModulesDirectory { return true; } - const real = files.realpath(path); - if (real !== path) { + const real = realpathOrNull(path); + if (typeof real === "string" && + real !== path) { // If node_modules/.bin/command is a symlink, determine the // answer by calling isWithinProdPackage(real). return isWithinProdPackage(real); @@ -521,6 +522,15 @@ export class NodeModulesDirectory { } } +function realpathOrNull(path) { + try { + return files.realpath(path); + } catch (e) { + if (e.code !== "ENOENT") throw e; + return null; + } +} + /////////////////////////////////////////////////////////////////////////////// // File ///////////////////////////////////////////////////////////////////////////////