GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `--env-file` watch · Issue #54001 · nodejs/node

--env-file watch #54001

New issue
Copy link
New issue
Copy link
Closed
#54109
Closed
--env-file watch#54001
#54109
Copy link
Labels
dotenvIssues and PRs related to .env file parsing.Issues and PRs related to .env file parsing.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.watch-modeIssues and PRs related to watch mode.Issues and PRs related to watch mode.

Description

@OliverJAsh
OliverJAsh
opened on Jul 23, 2024
Issue body actions

What is the problem this feature will solve?

We already have --env-file and --watch:

$ node --env-file=.env --watch test.js

However, it seems we're missing the ability to watch the env file. The command above will not restart the script when the env file changes.

--watch-path=.env doesn't help either. It does restart the script when the env file changes, however the env file is not loaded again, so the script only has access to the environment variables that were loaded when the command was first ran.

What is the feature you are proposing to solve the problem?

A flag to watch the env file e.g. --watch-env-file.

What alternatives have you considered?

No response

Reacted by Simon Tremblay and Andrew Plummer

Activity

  1. OliverJAsh
    added
    feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
    on Jul 23, 2024
  2. github-project-automation
    added this to Node.js feature requestson Jul 23, 2024
  3. github-project-automation
    moved this to Awaiting Triage in Node.js feature requestson Jul 23, 2024
  4. MoLow
    added
    good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
    watch-modeIssues and PRs related to watch mode.Issues and PRs related to watch mode.
    on Jul 23, 2024
  5. MoLow commented on Jul 23, 2024

    @MoLow
    MoLow
    on Jul 23, 2024
    Member
    More actions

    this should probably be the default, without an extra flag

  6. avivkeller
    added
    dotenvIssues and PRs related to .env file parsing.Issues and PRs related to .env file parsing.
    on Jul 23, 2024
  7. avivkeller
    moved this from Awaiting Triage to Triaged in Node.js feature requestson Jul 23, 2024
  8. tniessen commented on Jul 23, 2024

    @tniessen
    tniessen
    on Jul 23, 2024
    Member
    More actions

    --watch-path=.env doesn't help either. It does restart the script when the env file changes, however the env file is not loaded again, so the script only has access to the environment variables that were loaded when the command was first ran.

    I assume that the node process loads .env, then starts the actual application as a child process with the same --env-file flag. This should cause the child process to load the environment file upon start, however, the child process inherits the environment variables from the parent process, and inherited environment variables take precedence over variables read from .env, so you wouldn't see any changes to existing environment variables.

    To test this hypothesis, could you check if you can see new variables in the child process when you add a new entry to .env while --watch is running?

  9. OliverJAsh commented on Jul 23, 2024

    @OliverJAsh
    OliverJAsh
    on Jul 23, 2024
    Author
    More actions

    To test this hypothesis, could you check if you can see new variables in the child process when you add a new entry to .env while --watch is running?

    I just tested this and I can! You're right.

  10. nodejs-github-bot
    closed this as completedin #54109on Aug 5, 2024
  11. nodejs-github-bot
    added a commit that references this issue on Aug 5, 2024

    watch: reload changes in contents of --env-file

    a816688
  12. targos
    added a commit that references this issue on Aug 14, 2024

    watch: reload changes in contents of --env-file

    4d8b53e
  13. avivkeller
    moved this from Triaged to Done in Node.js feature requestson Aug 18, 2024
  14. avivkeller
    removed this from Node.js feature requestson Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotenvIssues and PRs related to .env file parsing.Issues and PRs related to .env file parsing.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.watch-modeIssues and PRs related to watch mode.Issues and PRs related to watch mode.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.