diff --git a/e2e/node/src/node.test.ts b/e2e/node/src/node.test.ts index febf9604647efd..e07c67f6435848 100644 --- a/e2e/node/src/node.test.ts +++ b/e2e/node/src/node.test.ts @@ -144,6 +144,43 @@ describe('Node Applications', () => { expect(additionalResult).toContain('Hello Additional World!'); }, 60000); + it('should be able to generate an empty application with variable in .env file', async () => { + const originalEnvPort = process.env.PORT; + const port = 3457; + process.env.PORT = `${port}`; + const nodeapp = uniq('nodeapp'); + + runCLI( + `generate @nx/node:app ${nodeapp} --linter=eslint --bundler=webpack --framework=none` + ); + await setMaxWorkers(); + + updateFile('.env', `NX_FOOBAR="test foo bar"`); + + updateFile( + `apps/${nodeapp}/src/main.ts`, + `console.log('foobar: ' + process.env['NX_FOOBAR']);` + ); + + await runCLIAsync(`build ${nodeapp}`); + checkFilesExist(`dist/apps/${nodeapp}/main.js`); + + // check serving + const p = await runCommandUntil( + `serve ${nodeapp} --port=${port}`, + (output) => { + process.stdout.write(output); + return output.includes(`foobar: test foo bar`); + } + ); + try { + await promisifiedTreeKill(p.pid, 'SIGKILL'); + await killPorts(port); + } finally { + process.env.port = originalEnvPort; + } + }, 60000); + it('should be able to generate an express application', async () => { const nodeapp = uniq('nodeapp'); const originalEnvPort = process.env.PORT; diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 63c8a67a7d70df..396222be65601e 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -36,7 +36,6 @@ "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", "detect-port": "^1.5.1", - "dotenv": "~16.3.1", "semver": "7.5.3", "tslib": "^2.3.0", "@nx/devkit": "file:../devkit", diff --git a/packages/cypress/src/executors/cypress/cypress.impl.ts b/packages/cypress/src/executors/cypress/cypress.impl.ts index 27ca6aed517921..7a86df95b3f656 100644 --- a/packages/cypress/src/executors/cypress/cypress.impl.ts +++ b/packages/cypress/src/executors/cypress/cypress.impl.ts @@ -10,7 +10,6 @@ import { output, } from '@nx/devkit'; import { getExecutorInformation } from 'nx/src/command-line/run/executor-utils'; -import 'dotenv/config'; import { existsSync, readdirSync, unlinkSync, writeFileSync } from 'fs'; import { basename, dirname, join } from 'path'; import { getTempTailwindPath } from '../../utils/ct-helpers'; diff --git a/packages/esbuild/package.json b/packages/esbuild/package.json index 27b7137ff237a0..42f0ed771d2e87 100644 --- a/packages/esbuild/package.json +++ b/packages/esbuild/package.json @@ -30,7 +30,6 @@ }, "dependencies": { "chalk": "^4.1.0", - "dotenv": "~16.3.1", "fast-glob": "3.2.7", "fs-extra": "^11.1.0", "tslib": "^2.3.0", diff --git a/packages/esbuild/src/executors/esbuild/esbuild.impl.ts b/packages/esbuild/src/executors/esbuild/esbuild.impl.ts index 2dea65586078e0..f9d7c4b6f1b069 100644 --- a/packages/esbuild/src/executors/esbuild/esbuild.impl.ts +++ b/packages/esbuild/src/executors/esbuild/esbuild.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import * as chalk from 'chalk'; import type { ExecutorContext } from '@nx/devkit'; import { cacheDir, joinPathFragments, logger, stripIndents } from '@nx/devkit'; diff --git a/packages/jest/package.json b/packages/jest/package.json index 8d15dafb2255c7..b626d67894dba8 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -38,7 +38,6 @@ "@jest/test-result": "^29.4.1", "@phenomnomnominal/tsquery": "~5.0.1", "chalk": "^4.1.0", - "dotenv": "~16.3.1", "identity-obj-proxy": "3.0.0", "jest-config": "^29.4.1", "jest-resolve": "^29.4.1", diff --git a/packages/jest/src/executors/jest/jest.impl.ts b/packages/jest/src/executors/jest/jest.impl.ts index 193bc9b82649b8..2c8210d5cb89f1 100644 --- a/packages/jest/src/executors/jest/jest.impl.ts +++ b/packages/jest/src/executors/jest/jest.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { runCLI } from 'jest'; import { readConfig, readConfigs } from 'jest-config'; import { utils as jestReporterUtils } from '@jest/reporters'; diff --git a/packages/next/package.json b/packages/next/package.json index a71714c7a64a63..c050f395619029 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -38,7 +38,6 @@ "@svgr/webpack": "^8.0.1", "chalk": "^4.1.0", "copy-webpack-plugin": "^10.2.4", - "dotenv": "~16.3.1", "fs-extra": "^11.1.0", "ignore": "^5.0.4", "semver": "7.5.3", diff --git a/packages/next/src/executors/build/build.impl.ts b/packages/next/src/executors/build/build.impl.ts index a08c7f795b12aa..10b8d44b0a93b0 100644 --- a/packages/next/src/executors/build/build.impl.ts +++ b/packages/next/src/executors/build/build.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, logger, diff --git a/packages/next/src/executors/export/export.impl.ts b/packages/next/src/executors/export/export.impl.ts index 75d9c7ff5c7be7..417fabeb59f1d1 100644 --- a/packages/next/src/executors/export/export.impl.ts +++ b/packages/next/src/executors/export/export.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, parseTargetString, diff --git a/packages/next/src/executors/server/custom-server.impl.ts b/packages/next/src/executors/server/custom-server.impl.ts index d360c8a6051066..0c7f30794ea0f2 100644 --- a/packages/next/src/executors/server/custom-server.impl.ts +++ b/packages/next/src/executors/server/custom-server.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, parseTargetString, runExecutor } from '@nx/devkit'; import { join } from 'path'; diff --git a/packages/next/src/executors/server/server.impl.ts b/packages/next/src/executors/server/server.impl.ts index f5f83e4f606018..50aed2c4176558 100644 --- a/packages/next/src/executors/server/server.impl.ts +++ b/packages/next/src/executors/server/server.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, parseTargetString, diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 2a1eda40b34c73..b52aca1e9e93fe 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -29,7 +29,6 @@ }, "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", - "dotenv": "~16.3.1", "fs-extra": "^11.1.0", "tslib": "^2.3.0", "@nx/devkit": "file:../devkit", diff --git a/packages/plugin/src/executors/e2e/e2e.impl.ts b/packages/plugin/src/executors/e2e/e2e.impl.ts index f29ca0a2f3983b..19de9a4bb72d97 100644 --- a/packages/plugin/src/executors/e2e/e2e.impl.ts +++ b/packages/plugin/src/executors/e2e/e2e.impl.ts @@ -1,5 +1,3 @@ -import 'dotenv/config'; - import type { ExecutorContext } from '@nx/devkit'; import { diff --git a/packages/rollup/package.json b/packages/rollup/package.json index b2c2041a95cb5d..24e1c2f18a3516 100644 --- a/packages/rollup/package.json +++ b/packages/rollup/package.json @@ -37,7 +37,6 @@ "autoprefixer": "^10.4.9", "babel-plugin-transform-async-to-promises": "^0.8.15", "chalk": "^4.1.0", - "dotenv": "~16.3.1", "fast-glob": "^3.2.7", "postcss": "^8.4.14", "rollup": "^2.56.2", diff --git a/packages/rollup/src/executors/rollup/rollup.impl.ts b/packages/rollup/src/executors/rollup/rollup.impl.ts index c07ed5053ca4e1..687ccadaeabd91 100644 --- a/packages/rollup/src/executors/rollup/rollup.impl.ts +++ b/packages/rollup/src/executors/rollup/rollup.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import * as ts from 'typescript'; import * as rollup from 'rollup'; import * as peerDepsExternal from 'rollup-plugin-peer-deps-external'; diff --git a/packages/storybook/package.json b/packages/storybook/package.json index 526f803d47187b..7828c521f8c09f 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -30,7 +30,6 @@ "migrations": "./migrations.json" }, "dependencies": { - "dotenv": "~16.3.1", "@phenomnomnominal/tsquery": "~5.0.1", "semver": "7.5.3", "tslib": "^2.3.0", diff --git a/packages/storybook/src/executors/build-storybook/build-storybook.impl.ts b/packages/storybook/src/executors/build-storybook/build-storybook.impl.ts index 5d825594761ee5..6b437c71157d07 100644 --- a/packages/storybook/src/executors/build-storybook/build-storybook.impl.ts +++ b/packages/storybook/src/executors/build-storybook/build-storybook.impl.ts @@ -1,7 +1,6 @@ import { ExecutorContext, logger } from '@nx/devkit'; import * as build from '@storybook/core-server'; import { CLIOptions } from '@storybook/types'; -import 'dotenv/config'; import { pleaseUpgrade, storybookConfigExistsCheck, diff --git a/packages/storybook/src/executors/storybook/storybook.impl.ts b/packages/storybook/src/executors/storybook/storybook.impl.ts index 99b900617fb84d..27fdfc92e79a2b 100644 --- a/packages/storybook/src/executors/storybook/storybook.impl.ts +++ b/packages/storybook/src/executors/storybook/storybook.impl.ts @@ -1,6 +1,5 @@ import { ExecutorContext, logger } from '@nx/devkit'; import * as build from '@storybook/core-server'; -import 'dotenv/config'; import { pleaseUpgrade, storybookConfigExistsCheck, diff --git a/packages/storybook/src/executors/utils.ts b/packages/storybook/src/executors/utils.ts index fac27968c24433..47500706dd7e27 100644 --- a/packages/storybook/src/executors/utils.ts +++ b/packages/storybook/src/executors/utils.ts @@ -2,7 +2,6 @@ import { joinPathFragments, logger } from '@nx/devkit'; import { findNodes } from '@nx/js'; -import 'dotenv/config'; import { existsSync, readFileSync } from 'fs'; import { join } from 'path'; import { gte } from 'semver'; diff --git a/packages/vite/package.json b/packages/vite/package.json index c05638249e292a..ed9f35ffc88740 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -31,7 +31,6 @@ "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", "@swc/helpers": "~0.5.0", - "dotenv": "~16.3.1", "enquirer": "~2.3.6", "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", diff --git a/packages/vite/src/executors/build/build.impl.ts b/packages/vite/src/executors/build/build.impl.ts index 24649df190cf55..b534b7885df534 100644 --- a/packages/vite/src/executors/build/build.impl.ts +++ b/packages/vite/src/executors/build/build.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, logger, diff --git a/packages/vite/src/executors/dev-server/dev-server.impl.ts b/packages/vite/src/executors/dev-server/dev-server.impl.ts index 2ed3171b35bf72..5e5456bc9f1392 100644 --- a/packages/vite/src/executors/dev-server/dev-server.impl.ts +++ b/packages/vite/src/executors/dev-server/dev-server.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext } from '@nx/devkit'; import { createServer, InlineConfig, mergeConfig, ViteDevServer } from 'vite'; diff --git a/packages/webpack/package.json b/packages/webpack/package.json index cece6cd013be8f..d3bf4b262403f8 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -38,7 +38,6 @@ "copy-webpack-plugin": "^10.2.4", "css-loader": "^6.4.0", "css-minimizer-webpack-plugin": "^5.0.0", - "dotenv": "~16.3.1", "fork-ts-checker-webpack-plugin": "7.2.13", "ignore": "^5.0.4", "less": "4.1.3", diff --git a/packages/webpack/src/executors/webpack/webpack.impl.ts b/packages/webpack/src/executors/webpack/webpack.impl.ts index 6376cfd7629bed..695e52f39b9927 100644 --- a/packages/webpack/src/executors/webpack/webpack.impl.ts +++ b/packages/webpack/src/executors/webpack/webpack.impl.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import { ExecutorContext, logger, stripIndents } from '@nx/devkit'; import { eachValueFrom } from '@nx/devkit/src/utils/rxjs-for-await'; import type { Configuration, Stats } from 'webpack';