Gathering detailed insights and metrics for @startupjs/babel-plugin-dotenv-import
Gathering detailed insights and metrics for @startupjs/babel-plugin-dotenv-import
Gathering detailed insights and metrics for @startupjs/babel-plugin-dotenv-import
Gathering detailed insights and metrics for @startupjs/babel-plugin-dotenv-import
Load environment variables using import statements.
npm install @startupjs/babel-plugin-dotenv-import
Typescript
Module System
Node Version
NPM Version
JavaScript (96.13%)
Shell (3.87%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
78 Stars
507 Commits
8 Forks
1 Watchers
7 Branches
6 Contributors
Updated on Apr 24, 2025
Latest Version
1002.0.0
Package Id
@startupjs/babel-plugin-dotenv-import@1002.0.0
Unpacked Size
16.11 kB
Size
5.97 kB
File Count
45
NPM Version
6.9.0
Node Version
10.16.0
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
1
5
Load environment variables using
import
statements.
1$ npm install babel-plugin-dotenv-import
.babelrc
1{ 2 "plugins": [ 3 ["dotenv-import", { 4 "moduleName": "@env", 5 "path": ".env", 6 "blacklist": null, 7 "whitelist": null, 8 "safe": false, 9 "allowUndefined": false 10 }] 11 ] 12}
.env
1API_URL=https://api.example.org 2API_TOKEN=
In users.js
1import {API_URL, API_TOKEN} from "@env" 2 3fetch(`${API_URL}/users`, { 4 headers: { 5 'Authorization': `Bearer ${API_TOKEN}` 6 } 7})
It is possible to limit the scope of env variables that will be imported by specifying a whitelist
and/or a blacklist
as an array of strings.
1{ 2 "plugins": [ 3 ["dotenv-import", { 4 "blacklist": [ 5 "GITHUB_TOKEN" 6 ] 7 }] 8 ] 9}
1{ 2 "plugins": [ 3 ["dotenv-import", { 4 "whitelist": [ 5 "API_URL", 6 "API_TOKEN" 7 ] 8 }] 9 ] 10}
Enable safe mode to only allow environment variables defined in the .env
file. This will completely ignore everything that is already defined in the environment.
The .env
file has to exist.
1{ 2 "plugins": [ 3 ["dotenv-import", { 4 "safe": true 5 }] 6 ] 7}
Allow importing undefined variables, their value will be undefined
.
1{ 2 "plugins": [ 3 ["dotenv-import", { 4 "allowUndefined": true 5 }] 6 ] 7}
1import {UNDEFINED_VAR} from '@env' 2 3console.log(UNDEFINED_VAR === undefined) // true
When false
(default behavior), an error will be thrown.
When using with babel-loader
with caching enabled you will run into issues where environment changes won’t be picked up.
This is due to the fact that babel-loader
computes a cacheIdentifier
that does not take your environment into account.
You can easily clear the cache:
1rm -rf node_modules/.cache/babel-loader/*
Or you can override the default cacheIdentifier
to include some of your environment variables.
Based on David Chang’s works on babel-plugin-dotenv.
╚⊙ ⊙╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/8 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
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
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