nitrojs / nitrojs/nitro

Support `.env` file for production / preview node preset

Open
#1,492 8 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement node nuxt v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

It is quite often required to test production Node.js preset outputs with dotenv file. I am thinking of 3 possible ways:

  • Change preview command to node -r require/dotenv .output/server/index.mjs (user needs dotenv local dependency)
  • Support a preview command used by nitro (and other frameworks such as nuxi)
  • Enable feature by default (as a bundled runtime)
  • Enable feature behind a flag (can be enabled by a CLI flag)

Need to check how much is actual runtime overhead of dotenv (it seems as low as 5KB).

Also worth to node that, the "local" kind presets (Bun and Deno) both already have built-in dotenv support via CLI args. And there is an ongoing discussion within Node.js team to make it build-in feature..

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 by inspecting the production and preview Node.js preset behavior and the preview command used to launch .output/server/index.mjs. Compare the proposed dotenv dependency, Nitro-style preview command, bundled runtime, and CLI-flag approaches, including runtime overhead. Done means selecting and documenting one supported approach with coverage for production and preview outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.