{"id":19448,"library":"dotenv-flow-webpack","title":"dotenv-flow-webpack","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/kerimdzhanov/dotenv-flow-webpack","tags":["javascript","dotenv-flow","webpack","node_env","process.env","development","test","production","local"],"install":[{"cmd":"npm install dotenv-flow-webpack","lang":"bash","label":"npm"},{"cmd":"yarn add dotenv-flow-webpack","lang":"bash","label":"yarn"},{"cmd":"pnpm add dotenv-flow-webpack","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is CommonJS-only; no ESM export. Use require in Node/webpack config files.","wrong":"import DotenvFlow from 'dotenv-flow-webpack';","symbol":"DotenvFlow","correct":"const DotenvFlow = require('dotenv-flow-webpack');"},{"note":"For TypeScript with esModuleInterop:false, use import = require. For esModuleInterop:true, use import DotenvFlow from ... but note no default export.","wrong":"import { DotenvFlow } from 'dotenv-flow-webpack';","symbol":"DotenvFlow (TypeScript)","correct":"import DotenvFlow = require('dotenv-flow-webpack');"},{"note":"When Node package type is 'module', use createRequire to load CJS packages.","wrong":"import DotenvFlow from 'dotenv-flow-webpack';","symbol":"package.json type module","correct":"import { createRequire } from 'module'; const require = createRequire(import.meta.url); const DotenvFlow = require('dotenv-flow-webpack');"}],"quickstart":{"code":"// webpack.config.js\nconst DotenvFlow = require('dotenv-flow-webpack');\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new DotenvFlow({\n      path: path.join(__dirname, './env'),  // custom .env* files directory\n      default_node_env: 'development',\n      node_env: process.env.NODE_ENV || 'development',\n      pattern: '.env[.node_env][.local]',  // custom pattern (v2.0.0+)\n      debug: !!process.env.DEBUG,  // enable debug logging\n      silent: false,  // turn off warnings\n    }),\n  ],\n};","lang":"javascript","description":"Shows minimal webpack.config.js using DotenvFlow with custom path, environment defaults, pattern, debug, and silent options."},"warnings":[{"fix":"Set options.pattern explicitly to your expected pattern, e.g., '.env[.node_env][.local]' or upgrade file naming to match default.","message":"v2.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.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove 'prefix' and 'safe' options. Use dotenv-flow-native 'pattern' and 'silent' options instead.","message":"Options 'prefix' and 'safe' from dotenv-webpack are not supported.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Rebuild your application after changing .env files. Or use system environment variables in production.","message":"Variables are only replaced at build time. Runtime changes to .env files or environment variables will not affect built bundles.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure all used environment variables are defined in your .env* files or set in the OS environment.","message":"All referenced process.env.* variables must exist in .env* files or system environment, otherwise they become undefined (or empty string if not found).","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Upgrade to webpack 5. If you must use webpack 4, stay on v1.x.","message":"Webpack 5 required peer dependency; may break with webpack 4 if using certain advanced features like pattern.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install dotenv-flow-webpack --save-dev' (or yarn add).","cause":"Package not installed or missing from node_modules.","error":"Module not found: Can't resolve 'dotenv-flow-webpack'"},{"fix":"Use 'const DotenvFlow = require('dotenv-flow-webpack');' instead of 'import DotenvFlow from ...'.","cause":"Incorrect import style - using ES6 import on a CJS-only package.","error":"TypeError: DotenvFlow is not a constructor"},{"fix":"Check options: only 'node_env', 'default_node_env', 'path', 'pattern', 'debug', 'silent' are allowed.","cause":"Passing invalid or misspelled options (e.g., 'safe', 'prefix' from dotenv-webpack).","error":"Invalid options object. DotenvFlow has been initialized using an options object that does not match the API schema."},{"fix":"Install the package: 'npm install dotenv-flow-webpack --save-dev'. Ensure node_modules is in require path.","cause":"Package not installed or node_modules path issue.","error":"Error: Cannot find module 'dotenv-flow-webpack'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}