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

Node.js DOTENV_KEY not triggering a vault loading #322

Open
RemyMachado opened this issue Dec 4, 2023 · 0 comments
Open

Node.js DOTENV_KEY not triggering a vault loading #322

RemyMachado opened this issue Dec 4, 2023 · 0 comments

Comments

@RemyMachado
Copy link

Hey, I'm not sure I understand the current example of Node.js DOTENV_KEY setup.

The current README.md:

node index.js

// console.log(result.parsed) // { HELLO: 'Universe' }
// console.log(result.parsed.HELLO) // 'Universe'
// console.log(process.env.HELLO) // undefined (as intentioned)

When I remove the .env file to try loading it with the vault and the DOTENV_KEY the project fails to load the vault.
I was using:

const envName = process.env.NODE_ENV
const envFilePath = `.env.${envName}`
dotenv.config({ path: envFilePath })
console.info('environment loaded:', envFilePath)

I thought maybe I should only use the following:

dotenv.config()

But none of these two approach worked.
The commands I have tried without success:
$ DOTENV_KEY=*** yarn start
$ DOTENV_KEY=*** NODE_ENV=development yarn start

Note that DOTENV_KEY and NODE_ENV correctly appear inside process.env while running, but the env file is not loaded.

In the meantime, I'll simply decrypt the vault with the decrypt command, but I thought that the magic DOTENV_KEY was cool to use.

Also I'm not sure how dotenv.config() is supposed to check for the DOTENV_KEY when it's related to the dotenv-vault feature. Shouldn't it be replaced with dotenvVault.config() while adding dotenv-vault as a dependency to the project?


I reopened this issue here, since I'm not sure it will ever be read on the initial repository where I posted it.

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

1 participant