From 83a40a458c4958d043969356007d9cda2937534b Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Mon, 23 Oct 2023 11:56:33 -0600 Subject: [PATCH] fix(core): Ensure require('nx') to resolve correctly closes: #19782 --- .../module-federation-dev-server.impl.ts | 3 ++- .../module-federation-dev-server.impl.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts b/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts index 32b89533dcaea..d923b39c89085 100644 --- a/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts +++ b/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts @@ -27,7 +27,8 @@ export function executeModuleFederationDevServerBuilder( schema: Schema, context: import('@angular-devkit/architect').BuilderContext ): ReturnType { - const nxBin = require.resolve('nx'); + // Force Node to resolve to look for the nx binary that is inside node_modules + const nxBin = require.resolve('nx/bin/nx'); const { ...options } = schema; const projectGraph = readCachedProjectGraph(); const { projects: workspaceProjects } = diff --git a/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts b/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts index 94d24da7819ae..b8c7ee75e2985 100644 --- a/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts +++ b/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts @@ -40,7 +40,8 @@ export default async function* moduleFederationDevServer( options: ModuleFederationDevServerOptions, context: ExecutorContext ): AsyncIterableIterator<{ success: boolean; baseUrl?: string }> { - const nxBin = require.resolve('nx'); + // Force Node to resolve to look for the nx binary that is inside node_modules + const nxBin = require.resolve('nx/bin/nx'); const currIter = options.static ? fileServerExecutor( {