Skip to content

.env.local environment variables are not being picked up after upgrading from NX v18 to v19 #23362

Closed as not planned
@barrymichaeldoyle

Description

Current Behavior

Before I updated my project from NX v18 to v19, my environment variables e.g. NX_USE_MSW in .env.local would work perfectly fine. I could log it out. Now that I've updated to v19, it logs out as undefined instead of the value I set it to.

When I move back to my branch with v18, everything works fine again.

Expected Behavior

I expect my environment variables to work when updating, or I expect a docs update on the migration required here.

GitHub Repo

No response

Steps to Reproduce

  1. Create a .env.local file at the root of the NX Project
  2. Add a value there like NX_SOME_KEY=SOME_VALUE
  3. Add a console log to process.env["NX_SOME_KEY"]
  4. Serve your app
  5. It will log undefined, instead of the expected "SOME_VALUE"

Nx Report

Node   : 20.12.0
OS     : linux-arm64
npm    : 10.5.0

nx                 : 19.0.3
@nx/js             : 19.0.3
@nx/jest           : 19.0.3
@nx/linter         : 19.0.3
@nx/eslint         : 19.0.3
@nx/workspace      : 19.0.3
@nx/cypress        : 19.0.3
@nx/devkit         : 19.0.3
@nx/eslint-plugin  : 19.0.3
@nx/playwright     : 19.0.3
@nx/react          : 19.0.3
@nx/storybook      : 19.0.3
@nrwl/tao          : 19.0.3
@nx/web            : 19.0.3
@nx/webpack        : 19.0.3
typescript         : 5.4.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I'm using module federation and running the project in a dev-container if that might have anything to do with it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions