Gathering detailed insights and metrics for envars
Gathering detailed insights and metrics for envars
Gathering detailed insights and metrics for envars
Gathering detailed insights and metrics for envars
Load environment variables securely from .env files, with seamless integration for Google Secret Manager to handle referenced secrets.
npm install envars
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
11 Stars
20 Commits
2 Watchers
1 Branches
2 Contributors
Updated on Jul 01, 2025
Latest Version
1.1.1
Package Id
envars@1.1.1
Unpacked Size
17.54 kB
Size
6.08 kB
File Count
5
NPM Version
11.3.0
Node Version
22.14.0
Published on
Jun 24, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
envars
— environment variables loaderLoads environment variables for the target environment from .env
files using dotenv; supports cloud secret providers such as Google Secret Manager.
By default it attempts to load .env
files from the current working directory using the following naming convention (learn more):
1.env.<environment>.local # Local overrides for <environment> 2.env.<environment> # Environment-specific settings 3.env.local # Local overrides 4.env # Default settings
Created and diligently upheld with the generous backing of these exceptional companies:
1# with NPM 2$ npm install envars --save-dev 3 4# with Yarn 5$ yarn add envars --dev
1# .env 2# Environment variables for the local development environment 3# NOTE: Secret values need to follow this format: 4# secret://[provider]/[resource] 5GOOGLE_CLOUD_PROJECT=example 6DB_PASSWORD=secret://google/projects/example/secrets/db-password/latest
1// core/env.ts 2import { cleanEnv, str } from "envalid"; 3 4/** 5 * Sanitized and validated environment variables. 6 * @see https://github.com/af/envalid#readme 7 */ 8export default cleanEnv(process.env, { 9 GOOGLE_CLOUD_PROJECT: str(), 10 DB_PASSWORD: str(), 11});
1import { loadEnv } from "envars"; 2 3const [env] = await loadEnv("production", { 4 root: ".", 5 schema: "./core/env.ts", 6 mergeTo: process.env, 7});
Type: string
(optional)
Default: undefined
Example: production
, development
, staging
, etc.
Type: object
(optional)
Type: string
(optional)
Default: .
(current working directory).
The root directory where it looks for .env
files.
Type: string
(optional)
Default: undefined
Example: ./core/env.ts
The path to the TypeScript or JavaScript module exporting a sanitized environment object. Example:
1import { cleanEnv, str } from "envalid"; 2 3export default cleanEnv(process.env, { 4 GOOGLE_CLOUD_PROJECT: str(), 5 DB_PASSWORD: str(), 6});
Or, another example using Zod:
1import { z } from "zod"; 2 3export const env = z 4 .object({ 5 GOOGLE_CLOUD_PROJECT: z.string(), 6 DB_PASSWORD: z.string(), 7 }) 8 .parse(process.env);
Type: string[]
(optional)
Default: [ ".env.<environment>.local", ".env.<environment>", ".env.local", ".env" ]
The list of file patterns where to look for .env
files.
Type: object
(optional)
Default: undefined
Example: process.env
The object where to merge the loaded environment variables.
1import { defineConfig } from "vite"; 2import { loadEnv } from "envars"; 3 4export default defineConfig(async ({ mode }) => { 5 const [env] = await loadEnv(mode, { 6 root: "../", 7 schema: "./core/env.ts", 8 mergeTo: process.env, 9 }); 10 11 return { 12 build: { 13 ssr: "index.ts", 14 target: "esnext", 15 sourcemap: true, 16 }, 17 }; 18});
Please fork the repo, create a PR, or send me a message on Discord (@koistya
).
1$ git clone https://github.com/<username>/envars.git 2$ cd ./envars 3$ corepack enable 4$ yarn test
Copyright © 2021-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE file.
Made with ♥ by Konstantin Tarkus (@koistya, blog) and contributors.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More