diff --git a/packages/metro/src/node-haste/DependencyGraph.js b/packages/metro/src/node-haste/DependencyGraph.js index 3eb0515d3c..22425f813d 100644 --- a/packages/metro/src/node-haste/DependencyGraph.js +++ b/packages/metro/src/node-haste/DependencyGraph.js @@ -117,9 +117,9 @@ class DependencyGraph extends EventEmitter { } _getClosestPackage(filePath: string): ?string { - const parsedPath = path.parse(filePath); - const root = parsedPath.root; - let dir = parsedPath.dir; + const {root} = path.parse(filePath); + // The `filePath` may be a directory. + let dir = filePath; do { const candidate = path.join(dir, 'package.json'); if (this._hasteFS.exists(candidate)) {