From 0961cb34d80c7792361dfe6db76c501b1fe62a79 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 13 Oct 2022 20:41:07 -0400 Subject: [PATCH] fix(core): do not run postinstall unless it is the main nx package (#12591) --- packages/nx/bin/compute-project-graph.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nx/bin/compute-project-graph.ts b/packages/nx/bin/compute-project-graph.ts index 0d50bdb8e9..19bcabfd73 100644 --- a/packages/nx/bin/compute-project-graph.ts +++ b/packages/nx/bin/compute-project-graph.ts @@ -6,7 +6,7 @@ import { daemonClient } from '../src/daemon/client/client'; (async () => { try { - if (fileExists(join(workspaceRoot, 'nx.json'))) { + if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) { try { await daemonClient.stop(); } catch (e) {} @@ -27,3 +27,11 @@ import { daemonClient } from '../src/daemon/client/client'; } } })(); + +function isMainNxPackage() { + const mainNxPath = require.resolve('nx', { + paths: [workspaceRoot], + }); + const thisNxPath = require.resolve('nx'); + return mainNxPath === thisNxPath; +}