nodejs / nodejs/node

Add option to process.loadEnvFile to not throw if no .env was found

Open
#61,086 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dotenv feature request
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

Most of my uses are for local development where I have a .env file. When actually deployed to production all variables are configured by prefixing the command, configuring k8s/docker variables, ... but almost never with a .env file. I think most people would want it to fail silently if no file was found. I'm not sure if you want to change that default in the next major version, but IMO at least a flag should be added

Also that's how dotenv behaved where I guess most node users would be switching from...

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

change signature to

function loadEnvFile(path?: string, { ignoreMissingFile?: boolean })
What alternatives have you considered?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the process.loadEnvFile entry point and inspect how its current arguments and missing-file errors are handled. Add the proposed ignoreMissingFile option while preserving the existing behavior by default, then verify that a missing .env file is ignored only when the option is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.