From a03c5fa4f6a1a6eac7e8216ae2d0b93fefe806f4 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Tue, 3 Dec 2024 10:10:11 +0000 Subject: [PATCH] fix(core): use getNxRequirePaths for more accurate locations of node_modules --- packages/workspace/src/generators/new/generate-preset.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/workspace/src/generators/new/generate-preset.ts b/packages/workspace/src/generators/new/generate-preset.ts index f69cd2b577c49..1b4ff94db1fcc 100644 --- a/packages/workspace/src/generators/new/generate-preset.ts +++ b/packages/workspace/src/generators/new/generate-preset.ts @@ -14,6 +14,7 @@ import { NormalizedSchema } from './new'; import { join } from 'path'; import * as yargsParser from 'yargs-parser'; import { fork, ForkOptions } from 'child_process'; +import { getNxRequirePaths } from 'nx/src/utils/installation-directory'; export function addPresetDependencies(host: Tree, options: NormalizedSchema) { const { dependencies, dev } = getPresetDependencies(options); @@ -39,8 +40,9 @@ export function generatePreset(host: Tree, opts: NormalizedSchema) { cwd: newWorkspaceRoot, }; const pmc = getPackageManagerCommand(); + const nxInstallationPaths = getNxRequirePaths(newWorkspaceRoot); const nxBinForNewWorkspaceRoot = require.resolve('nx/bin/nx', { - paths: [join(newWorkspaceRoot, 'node_modules')], + paths: nxInstallationPaths, }); const args = getPresetArgs(opts);