Registry / devops / dotenv-flow-webpack

dotenv-flow-webpack

JSON →
library2.0.0jsnpmunverified

A webpack plugin that integrates dotenv-flow's environment-based .env* file loading strategy into the webpack build process, securely replacing process.env references with actual values at build time. Current stable version: 2.0.0. Release cadence: minor versions as needed. Key differentiators: supports NODE_ENV-specific files (.env.development, .env.test, .env.production) and .env*.local overrides, follows CreateReactApp conventions, and only exposes variables explicitly used in code for security. Compared to dotenv-webpack, it adds environment cascading and pattern customization.

npm install dotenv-flow-webpack
INSTALL
IMPORT
SIG · DOTENV-FLOW-WEBPAC
D
dotenv-flow-webpack
devopsjavascriptv2.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DotenvFlow
✓ const DotenvFlow = require('dotenv-flow-webpack');
✗ import DotenvFlow from 'dotenv-flow-webpack';
The package is CommonJS-only; no ESM export. Use require in Node/webpack config files.
DotenvFlow (TypeScript)
✓ import DotenvFlow = require('dotenv-flow-webpack');
✗ import { DotenvFlow } from 'dotenv-flow-webpack';
For TypeScript with esModuleInterop:false, use import = require. For esModuleInterop:true, use import DotenvFlow from ... but note no default export.
package.json type module
✓ import { createRequire } from 'module'; const require = createRequire(import.meta.url); const DotenvFlow = require('dotenv-flow-webpack');
✗ import DotenvFlow from 'dotenv-flow-webpack';
When Node package type is 'module', use createRequire to load CJS packages.

Shows minimal webpack.config.js using DotenvFlow with custom path, environment defaults, pattern, debug, and silent options.

// webpack.config.js const DotenvFlow = require('dotenv-flow-webpack'); const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new DotenvFlow({ path: path.join(__dirname, './env'), // custom .env* files directory default_node_env: 'development', node_env: process.env.NODE_ENV || 'development', pattern: '.env[.node_env][.local]', // custom pattern (v2.0.0+) debug: !!process.env.DEBUG, // enable debug logging silent: false, // turn off warnings }), ], };
Debug
Known issues
breakingv2.0.0 changed default pattern from hardcoded to customizable. Ensure your file names match the new default pattern '.env[.node_env][.local]' if not using custom pattern.
fix
Set options.pattern explicitly to your expected pattern, e.g., '.env[.node_env][.local]' or upgrade file naming to match default.
affects: >=2.0.0
deprecatedOptions 'prefix' and 'safe' from dotenv-webpack are not supported.
fix
Remove 'prefix' and 'safe' options. Use dotenv-flow-native 'pattern' and 'silent' options instead.
affects: >=1.0.0
gotchaVariables are only replaced at build time. Runtime changes to .env files or environment variables will not affect built bundles.
fix
Rebuild your application after changing .env files. Or use system environment variables in production.
affects: >=0.0.1
gotchaAll referenced process.env.* variables must exist in .env* files or system environment, otherwise they become undefined (or empty string if not found).
fix
Ensure all used environment variables are defined in your .env* files or set in the OS environment.
affects: >=0.0.1
breakingWebpack 5 required peer dependency; may break with webpack 4 if using certain advanced features like pattern.
fix
Upgrade to webpack 5. If you must use webpack 4, stay on v1.x.
affects: >=2.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'dotenv-flow-webpack'
Package not installed or missing from node_modules.
fix
Run 'npm install dotenv-flow-webpack --save-dev' (or yarn add).
TypeError: DotenvFlow is not a constructor
Incorrect import style - using ES6 import on a CJS-only package.
fix
Use 'const DotenvFlow = require('dotenv-flow-webpack');' instead of 'import DotenvFlow from ...'.
Invalid options object. DotenvFlow has been initialized using an options object that does not match the API schema.
Passing invalid or misspelled options (e.g., 'safe', 'prefix' from dotenv-webpack).
fix
Check options: only 'node_env', 'default_node_env', 'path', 'pattern', 'debug', 'silent' are allowed.
Error: Cannot find module 'dotenv-flow-webpack'
Package not installed or node_modules path issue.
fix
Install the package: 'npm install dotenv-flow-webpack --save-dev'. Ensure node_modules is in require path.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
dotenv-flow-webpack — npm install dotenv-flow-webpack · libregistry