diff --git a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts index cab279a55b745..b12b0808c5a6a 100644 --- a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts +++ b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts @@ -181,7 +181,12 @@ export class TargetProjectLocator { private findProjectOfResolvedModule( resolvedModule: string ): string | undefined { - if (resolvedModule.startsWith('node_modules/')) return undefined; + if ( + resolvedModule.startsWith('node_modules/') || + resolvedModule.includes('/node_modules/') + ) { + return undefined; + } const normalizedResolvedModule = resolvedModule.startsWith('./') ? resolvedModule.substring(2) : resolvedModule;