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

NX monorepo support | You set DOTENV_KEY but you are missing a .env.vault file at .local.env.vault. Did you forget to build it? #335

Open
Husamui opened this issue Mar 19, 2024 · 3 comments

Comments

@Husamui
Copy link

Husamui commented Mar 19, 2024

we using NX monorepo for our projects.

Steps:

  1. We placed the .env.vault and env.keys files at the root directory of the nx monorepo.
  2. Run export DOTENV_KEY='dotenv:xxxxx in the command line before serving the app.
  3. calling require('dotenv').config(); in rootDirectory/apps/app_name/src/main.ts.

we got the following warnings in the console when serving the app even though the app server correctly and include the env variables (I believe because .env loading the env variables from step 2)

You set DOTENV_KEY but you are missing a .env.vault file at .local.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][INFO] Loading env from encrypted .env.vault
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .local.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .env.local.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.env.serve.development.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.env.development.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.serve.development.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.development.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.env.serve.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.serve.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.env.local.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at apps/api/.local.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][INFO] Loading env from encrypted .env.vault
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .env.serve.development.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .env.development.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .serve.development.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .development.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .env.serve.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .serve.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .local.env.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][WARN] You set DOTENV_KEY but you are missing a .env.vault file at .env.local.vault. Did you forget to build it?
[ NX] [dotenv@16.3.2][INFO] Loading env from encrypted .env.vault

any suggests?

@validkeys
Copy link

@Husamui try also setting an env variable DOTENV_CONFIG_PATH=path/to/.env.vault

then update your dotenv.config to use that path in its options

@validkeys
Copy link

@Husamui nevermind -- that was bad advice -- trying to sort through the same issue myself

@motdotla
Copy link
Member

@Husamui and @validkeys - dotenv-vault is possible to get going with monorepos but it's a bit awkward.

you need a .env.vaut and DOTENV_KEY per sub project under you monorepo

we have a better answer to monorepos with dotenvx. it has support for doing things like:

dotenvx encrypt
dotenvx encrypt apps/backend
dotenvx encrypt apps/frontend

so that you can have vaults per project in your monorepo. it's a much better experience.

but caveat: the hub (team) features of dotenvx are not comparable to dotenv-vault yet.

summary: once dotenvx's team features mature over the next 6 months, i would recommend choosing it over dotenv-vault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants