Gathering detailed insights and metrics for dotenv-cra
Gathering detailed insights and metrics for dotenv-cra
Gathering detailed insights and metrics for dotenv-cra
Gathering detailed insights and metrics for dotenv-cra
cra-template-sdw
The base SDW template for Create React App.
react-dotenv
Load environment variables dynamically for your React applications created with CRA (Create-React-App).
cra-template-orange
A Create React App Template with essential ready-to-code components and libraries.
cfs-dotenv
Load dotenv files like CRA in Create Full Stack.
Create React App style dotenv support for Node projects. Combine a base .env file with a .env.${NODE_ENV} file to create your optimum configuration.
npm install dotenv-cra
Typescript
Module System
Min. Node Version
Node Version
NPM Version
75.9
Supply Chain
99.4
Quality
75.9
Maintenance
100
Vulnerability
100
License
TypeScript (92.64%)
JavaScript (7.36%)
Total Downloads
767,745
Last Day
65
Last Week
3,585
Last Month
12,695
Last Year
171,060
MIT License
9 Stars
187 Commits
1 Forks
2 Watchers
15 Branches
3 Contributors
Updated on Mar 25, 2025
Minified
Minified + Gzipped
Latest Version
3.0.3
Package Id
dotenv-cra@3.0.3
Unpacked Size
9.78 kB
Size
4.04 kB
File Count
5
NPM Version
7.21.1
Node Version
16.19.0
Published on
Jan 20, 2023
Cumulative downloads
Total Downloads
Last Day
124.1%
65
Compared to previous day
Last Week
20.6%
3,585
Compared to previous week
Last Month
-17.5%
12,695
Compared to previous month
Last Year
-19%
171,060
Compared to previous year
2
2
Create React App style dotenv support for
Node projects. Combine a base .env
file with a .env.${NODE_ENV}
file to
create your optimum configuration.
Note: It's not recommended that you store secrets (like private API keys) in
your .env
file(s). Secret configuration values should be managed and provided
as part of your hosting solution.
npm i dotenv-cra
Not much new here. As with dotenv, import/require dotenv-cra
and configure it
as early as possible. This ensures that any modules reading values from
process.env
can retrieve the expected values.
⚠️ Warning: The NODE_ENV
variable must be set, so you may choose to default it
in your application before calling config()
.
1import { config } from 'dotenv-cra'; 2 3process.env.NODE_ENV = process.env.NODE_ENV || 'development'; 4config();
Note When using NodeJS v15 or higher you can use Logical Nullish Assignment as well:
1process.env.NODE_ENV ??= 'development';
At a minimum, create a base .env
file in the root directory of your project
with KEY=value
entires on each line. However, if that's all you ever do, you
don't need this library 😉. To see the real value of dotenv-cra, try creating a
second .env.development
file with some new and some overlapping KEY=value
pairs.
# .env
LOG_LEVEL=info
PORT=3001
# .env.development
LOG_LEVEL=debug
# Loaded into process.env
LOG_LEVEL=debug
PORT=3001
.env
files can be used?.env
: Default..env.local
: Local overrides. This file is loaded for all environments except test..env.development
, .env.test
, .env.production
: Environment-specific settings..env.development.local
, .env.test.local
, .env.production.local
: Local overrides of environment-specific settings.Files on the left have more priority than files on the right:
npm start
: .env.development.local
, .env.local
, .env.development
, .env
npm test
: .env.test.local
, .env.test
, .env
(note .env.local
is missing)Default: process.env.NODE_ENV
You may specify a custom environment if you don't want to base the .env.*
files you load on NODE_ENV
. For example, you may want NODE_ENV
set to
production
, but you want to load the .env.staging
file.
1dotenvCra.config({ env: process.env.AWS_ENV });
Default: none
You may specify a required prefix for your dotenv variables. For example, you
may want to prefix your variables with WEB_API_
to ensure there aren't any
collisions with other environment variables.
1dotenvCra.config({ prefix: 'WEB_API_' });
Default: path.resolve(process.cwd(), '.env')
You may specify a custom path if your file containing environment variables is
located elsewhere. This will also be used as the basis for resolving the other
.env.*
files.
1dotenvCra.config({ path: '/full/custom/path/to/your/.env' });
Default: utf8
You may specify the encoding of your file containing environment variables. Passed through to dotenv.
1dotenvCra.config({ encoding: 'latin1' });
Default: false
You may turn on logging to help debug why certain keys or values are not being set as you expect. Passed through to dotenv.
1dotenvCra.config({ debug: process.env.DEBUG });
Thanks to these projects for this simple yet powerful approach 👏
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 6
Details
Reason
Found 1/17 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
32 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-12
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