
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@jsdotenv/core
Advanced tools
Written in typescript, full testing.
It can loads environment variables from a .env
file into process.env
or parse <key>=<value>
string
npm i @jsdotenv/core
Add your application configuration to your .env
file in the root of your project:
S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE
Then in your Nodejs app you can do something like
import dotenv from "@jsdotenv/core";
dotenv.load([__dirname + "/.env"]);
console.log(process.env["S3_BUCKET"]);
If you want to be really fancy with your env file you can do comments and exports (below is a valid env file)
# I am a comment and that is OK
SOME_VAR=someval
FOO=BAR # comments at line end are OK too
export BAR=BAZ
Or finally you can do YAML(ish) style
FOO: bar
BAR: baz
Multiple line is OK.
MULTI_DOUBLE_QUOTED="THIS
IS
A
MULTILINE
STRING"
Expand variables is OK.
OPTION_B=${OPTION_A}
OPTION_C=$OPTION_B
OPTION_D=${OPTION_A}${OPTION_B}
OPTION_E=${OPTION_NOT_DEFINED}
dotenv can also write a map representing the environment to a correctly-formatted and escaped file.
const map = new Map();
map.set("BASIC", "basic");
map.set("KEY", "value");
const filepath = path.resolve(__dirname, "./jsfile/.env");
dotenv.write(map, filepath);
... or to a string
const map = new Map();
map.set("BASIC", "basic");
map.set("KEY", "value");
const lines = dotenv.marshal(map);
dotenv can run commands and inherit output.
exec bash commands
const pathname = path.resolve(__dirname + "/env/.env");
const out = dotenv.exec([pathname], "bash", ["-c", 'echo "$BASIC"']);
exec nodejs commands
const pathname = path.resolve(__dirname, "./jsfile/hello.js");
const out = dotenv.exec([], "node", [pathname]);
npm i create-dotenv -g
Execute commands using key-value pairs.
dotenv-cli -v KEY=VALUE -- bash -c 'echo "$KEY"'
Execute commands using enviroment file.
dotenv-cli -e .env -- bash -c 'echo "$BASIC"'
Execute commands --help for Usage
dotenv-cli --help
FAQs
Loads environment variables from .env file
The npm package @jsdotenv/core receives a total of 15 weekly downloads. As such, @jsdotenv/core popularity was classified as not popular.
We found that @jsdotenv/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.