{"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,"search_vec":"'2.0.0':39 'actual':31 'add':80 'base':16 'build':24,34 'cadenc':41 'cascad':82 'code':71 'compar':74 'convent':63 'createreactapp':62 'current':36 'custom':85 'develop':94 'differenti':47 'dotenv':2,11,77,88 'dotenv-flow':10,87 'dotenv-flow-webpack':1 'dotenv-webpack':76 'env':17,51,58,92 'env-specif':50 'env.development':54 'env.production':56 'env.test':55 'environ':15,81 'environment-bas':14 'explicit':68 'expos':66 'file':18,53 'flow':3,12,89 'follow':61 'integr':9 'javascript':86 'key':46 'load':19 'local':59,97 'minor':42 'need':45 'node':49,91 'overrid':60 'pattern':84 'plugin':7 'process':25 'process.env':28,93 'product':96 'refer':29 'releas':40 'replac':27 'secur':26,73 'specif':52 'stabl':37 'strategi':20 'support':48 'test':95 'time':35 'use':69 'valu':32 'variabl':67 'version':38,43 'webpack':4,6,23,78,90","created_at":"2026-04-25T11:17:51.684739+00:00","updated_at":"2026-04-25T11:17:51.684739+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kerimdzhanov/dotenv-flow-webpack","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/dotenv-flow-webpack","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}