diff --git a/.changeset/funny-oranges-switch.md b/.changeset/funny-oranges-switch.md new file mode 100644 index 0000000000..23c3104441 --- /dev/null +++ b/.changeset/funny-oranges-switch.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fixed a bug where `NODE_ENV` was not set in the environment when starting the backend in development mode. It has always been the case that Webpack transformed `NODE_ENV` when running in development mode, but this did not affect dependencies in `node_modules` as they are treated as external. diff --git a/packages/cli/src/lib/bundler/backend.ts b/packages/cli/src/lib/bundler/backend.ts index 1b161976e3..3094450d4b 100644 --- a/packages/cli/src/lib/bundler/backend.ts +++ b/packages/cli/src/lib/bundler/backend.ts @@ -26,6 +26,10 @@ export async function serveBackend(options: BackendServeOptions) { isDev: true, }); + // Webpack only replaces occurrences of this in code it touches, which does + // not include dependencies in node_modules. So we set it here at runtime as well. + (process.env as { NODE_ENV: string }).NODE_ENV = 'development'; + const compiler = webpack(config, (err: Error | undefined) => { if (err) { console.error(err);