From 52e07490d7681168601910c1ee9036ecb11a0e45 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Mon, 24 Apr 2023 12:26:10 -0400 Subject: [PATCH] fix(js): throw better error messaging when a dependency is not in the graph --- .../nx/src/plugins/js/package-json/create-package-json.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 f56adef38f4fb..a16e8115fb143 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.`); } } }