Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.npmrc environment variables override those in .env files #30298

Open
1 of 4 tasks
tlaurie-cl opened this issue Mar 7, 2025 · 0 comments
Open
1 of 4 tasks

.npmrc environment variables override those in .env files #30298

tlaurie-cl opened this issue Mar 7, 2025 · 0 comments

Comments

@tlaurie-cl
Copy link

tlaurie-cl commented Mar 7, 2025

Current Behavior

.npmrc environment variables override those in .env files described in the docs when nx is invoked npm run nx ... or npx nx ..., but not when invoked directly.

This behavior was observed using the NODE_OPTIONS=--max-old-space-size=8192 variable.

The docs suggest environment variables are overridden by those with the most specific scope. However an .npmrc file in any location: project, workspace root, external parent directories, or even the user's global .npmrc, will override .env variables.

Expected Behavior

.npmrc environment variables do not override those in .env files when when nx is invoked npm run nx ... or npx nx ....

If this cannot be fixed or is as-designed, I suggest adding a note in the docs to warn about this interaction. The cause is not obvious and is mistakable for a similar limitation of the dotenv package where the NODE_OPTIONS variable cannot be set while node is running.

GitHub Repo

https://github.com/tlaurie-cl/npmrc-overrides-nx-env

Steps to Reproduce

  1. Install nx globally:
    • npm install -g nx
  2. Run nx directly via:
    • nx run example:build
    • Notice the heap_size_limit is 8640266240 B (~8 GiB) (Intended limit from .env)
  3. Run nx with npm via:
    • npm run nx run example:build
    • Notice the heap_size_limit is 4345298944 B (~4 GiB) (Overridden limit from .npmrc)
  4. Run nx with npx via:
    • npx nx run example:build
    • Notice the heap_size_limit is 4345298944 B (~4 GiB) (Overridden limit from .npmrc)

Nx Report

Node           : 18.19.1
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.2.4

nx (global)  : 20.5.0
nx           : 20.5.0

Package Manager Version

10.2.4

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant