diff --git a/e2e/node/src/node.test.ts b/e2e/node/src/node.test.ts index e8ed0ee3fd8fb2..0ed51803d2e142 100644 --- a/e2e/node/src/node.test.ts +++ b/e2e/node/src/node.test.ts @@ -108,17 +108,22 @@ describe('Node Applications', () => { `apps/${nodeapp}/src/additional-main.ts`, `console.log('Hello Additional World!');` ); - updateFile(`apps/${nodeapp}/src/main.ts`, `console.log('Hello World!');`); + updateFile(`apps/${nodeapp}/src/main.ts`, + `console.log('Hello World!'); + console.log('env: ' + process.env['NODE_ENV']); + ` + ); await runCLIAsync(`build ${nodeapp}`); checkFilesExist( `dist/apps/${nodeapp}/main.js`, `dist/apps/${nodeapp}/additional-main.js` ); - const result = execSync(`node dist/apps/${nodeapp}/main.js`, { + const result = execSync(`NODE_ENV=development && node dist/apps/${nodeapp}/main.js`, { cwd: tmpProjPath(), }).toString(); expect(result).toContain('Hello World!'); + expect(result).toContain('env: development'); const additionalResult = execSync( `node dist/apps/${nodeapp}/additional-main.js`, diff --git a/packages/esbuild/src/executors/esbuild/esbuild.impl.ts b/packages/esbuild/src/executors/esbuild/esbuild.impl.ts index 872d35b1a771b7..239b74828bd209 100644 --- a/packages/esbuild/src/executors/esbuild/esbuild.impl.ts +++ b/packages/esbuild/src/executors/esbuild/esbuild.impl.ts @@ -41,7 +41,7 @@ export async function* esbuildExecutor( _options: EsBuildExecutorOptions, context: ExecutorContext ) { - process.env.NODE_ENV ??= context.configurationName; + process.env.NODE_ENV ??= context.configurationName ?? 'production'; const options = normalizeOptions(_options, context); if (options.deleteOutputPath) removeSync(options.outputPath); diff --git a/packages/js/src/executors/node/node.impl.ts b/packages/js/src/executors/node/node.impl.ts index 5571eab8e47ab7..d22b07bfe86d1b 100644 --- a/packages/js/src/executors/node/node.impl.ts +++ b/packages/js/src/executors/node/node.impl.ts @@ -36,6 +36,7 @@ export async function* nodeExecutor( options: NodeExecutorOptions, context: ExecutorContext ) { + process.env.NODE_ENV ??= context?.configurationName ?? 'development'; const project = context.projectGraph.nodes[context.projectName]; const buildTarget = parseTargetString( options.buildTarget,