diff --git a/packages/nx/src/daemon/client/client.ts b/packages/nx/src/daemon/client/client.ts index 7e54b14af59c6d..a2c6771853009f 100644 --- a/packages/nx/src/daemon/client/client.ts +++ b/packages/nx/src/daemon/client/client.ts @@ -29,7 +29,6 @@ import { DaemonProjectGraphError } from '../daemon-project-graph-error'; import { ProjectGraphError } from '../../project-graph/project-graph'; const DAEMON_ENV_SETTINGS = { - ...process.env, NX_PROJECT_GLOB_CACHE: 'false', NX_CACHE_PROJECTS_CONFIG: 'false', }; @@ -402,7 +401,7 @@ export class DaemonClient { detached: true, windowsHide: true, shell: false, - env: DAEMON_ENV_SETTINGS, + env: { ...process.env, ...DAEMON_ENV_SETTINGS }, } ); backgroundProcess.unref(); diff --git a/packages/nx/src/utils/dotenv.ts b/packages/nx/src/utils/dotenv.ts new file mode 100644 index 00000000000000..9876e150f983cd --- /dev/null +++ b/packages/nx/src/utils/dotenv.ts @@ -0,0 +1,17 @@ +import { config } from 'dotenv'; +import { expand } from 'dotenv-expand'; + +/** + * This loads dotenv files from: + * - .env + * - .local.env + * - .env.local + */ +export function loadRootDotEnvFiles() { + for (const file of ['.local.env', '.env.local', '.env']) { + const myEnv = config({ + path: file, + }); + expand(myEnv); + } +}