diff --git a/packages/nx/src/plugins/js/package-json/create-package-json.ts b/packages/nx/src/plugins/js/package-json/create-package-json.ts index f56adef38f4fbb..b42aea3ca33053 100644 --- a/packages/nx/src/plugins/js/package-json/create-package-json.ts +++ b/packages/nx/src/plugins/js/package-json/create-package-json.ts @@ -226,7 +226,7 @@ function findAllNpmDeps( seen.add(dep); npmDeps.dependencies[node.data.packageName] = node.data.version; recursivelyCollectPeerDependencies(node.name, graph, npmDeps, seen); - } else { + } else if (graph.nodes[dep]) { findAllNpmDeps( graph.nodes[dep], graph, @@ -234,6 +234,8 @@ function findAllNpmDeps( seen, dependencyPatterns ); + } else { + throw new Error(`Could not find ${dep} in the project graph.`) } } }