diff --git a/packages/nx/src/project-graph/plugins/loaded-nx-plugin.ts b/packages/nx/src/project-graph/plugins/loaded-nx-plugin.ts index c27cc5886c1b8..d07cf879a0048 100644 --- a/packages/nx/src/project-graph/plugins/loaded-nx-plugin.ts +++ b/packages/nx/src/project-graph/plugins/loaded-nx-plugin.ts @@ -121,26 +121,19 @@ export class LoadedNxPlugin { if (plugin.preTasksExecution) { this.preTasksExecution = async (context: PreTasksExecutionContext) => { const updates = {}; - let revokeFn: () => void; + let originalEnv = process.env; if (isIsolationEnabled() || isDaemonEnabled()) { - const { proxy, revoke } = Proxy.revocable( - process.env, - { - set: (target, key: string, value) => { - target[key] = value; - updates[key] = value; - return true; - }, - } - ); - process.env = proxy; - revokeFn = revoke; + process.env = new Proxy(originalEnv, { + set: (target, key: string, value) => { + target[key] = value; + updates[key] = value; + return true; + }, + }); } await plugin.preTasksExecution(this.options, context); + process.env = originalEnv; - if (revokeFn) { - revokeFn(); - } return updates; }; }