I have encountered an issue when using the .env file for certain projects in Node, specifically in the context of Nuxt3. The current workaround is to run Nuxt3 using node -r dotenv/config .output/server/index.mjs via PM2. However, this approach does not fully integrate "the nuxt" way.

Expected behavior:

  • The application should be able to read the .env file variables and apply them during execution.
  • Users should be able to modify variables, such as the PORT number, directly in the .env file.

Actual behavior:

-The .env file variables are not automatically added during the node execution.

  • Nuxt Users have to manually provide variables like the PORT number in the start command.

Additional context:

  • It would be beneficial to have the PORT number and other variables automatically added from the .env file.

Possible solution:

  • Improve the integration of .env files in Nuxt3 projects with PM2, allowing for seamless usage and configuration.

Example script to add to .sh file

#!/usr/bin/env sh

# Load variables from .env file. (only need to add the path to site dir here)
export $(cat ./.env | grep -v ^# | xargs) >/dev/null

// Talk to Ling for details.

You may use @ to mention someone.

NODEJS: PM2 -Improve .env file support and integration in node/Nuxt3 projects

2 total votes
Score Media BV SMIT.
  • Dennis moved item to board Planned

    1 year ago
  • Dennis moved item to board Under review

    1 year ago
  • SMIT. moved item to project Site Level Requests

    1 year ago
  • SMIT. created the item

    1 year ago