From db324007b52cd9c8340da007aae565407b2e4fdc Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Mon, 24 Apr 2023 16:50:11 -0400 Subject: [PATCH] fix(js): throw better error messaging when a dependency is not in the graph (#16510) --- .../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.`); } } }