From edd6fb50a62bb0075ec2846291285722e9a6c949 Mon Sep 17 00:00:00 2001 From: AgentEnder Date: Tue, 21 Feb 2023 18:46:47 -0500 Subject: [PATCH] fix(core): workspaceRoot/node_modules/.bin should be in path during `nx exec` --- packages/nx/src/command-line/exec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/command-line/exec.ts b/packages/nx/src/command-line/exec.ts index 18ed703a4f6b59..7532624b8bb287 100644 --- a/packages/nx/src/command-line/exec.ts +++ b/packages/nx/src/command-line/exec.ts @@ -5,7 +5,6 @@ import * as yargs from 'yargs-parser'; import { readNxJson } from '../config/configuration'; import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph'; -import { ProjectConfiguration } from '../config/workspace-json-project-json'; import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph, @@ -17,6 +16,7 @@ import { PackageJson } from '../utils/package-json'; import { getPackageManagerCommand } from '../utils/package-manager'; import { workspaceRoot } from '../utils/workspace-root'; import { calculateDefaultProjectName } from './run-one'; +import { env as appendLocalEnv } from 'npm-run-path'; export async function nxExecCommand( args: Record @@ -28,7 +28,13 @@ export async function nxExecCommand( const command = scriptArgV .reduce((cmd, arg) => cmd + `"${arg}" `, '') .trim(); - execSync(command, { stdio: 'inherit' }); + execSync(command, { + stdio: 'inherit', + env: { + ...process.env, + ...appendLocalEnv(), + }, + }); } else { // nx exec is being ran inside of Nx's context return runScriptAsNxTarget(scriptArgV);