Answer the question
In order to leave comments, you need to log in
How to dynamically export variables from .env file to use them when calling commands?
Itchy hands. But it doesn't work.
There is a file with variables .env
I use it in the project through dotenv
The project uses postgres
Also in package.json there are commands to fill the database.
"db:create" : "psql -h localhost -U postgres -f ./src/backend/database/sql/schema.sql",
"db:fill" : "psql -h localhost -U postgres -f ./src/backend/database/sql/fill-db.sql",
"db:drop" : "dropdb --if-exists -h localhost -U postgres -e typoteka",
"db:init" : "node -r ./config ./src/backend/database/db-init.js",
"db:all" : "cross-env COUNT=20 npm-run-all generate db:drop db:create db:init db:fill",
"db:all" : "cross-env COUNT=20 PGPASSWORD=password npm-run-all generate db:drop db:create db:init db:fill"
Answer the question
In order to leave comments, you need to log in
operating system - windows
Not working with node.js, but the dotenv documentation gives an example:
node -r dotenv/config your_script.js
process.env.DB_PASS
other secrets. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question