{"id":25230,"library":"envkey-webpack-plugin","title":"envkey-webpack-plugin","description":"A webpack plugin that wraps EnvKey's Node.js library to inject allow-listed environment variables from EnvKey into browser apps via process.env. Version 2.5.1 is stable; the package is part of the EnvKey ecosystem (encrypted environment variable management). Unlike generic dotenv plugins, this fetches variables from EnvKey servers using an ENVKEY, with an allow-list (permitted) to avoid leaking secrets. Requires webpack as a peer dependency. Release cadence is irregular, tied to EnvKey platform updates.","status":"active","version":"2.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/envkey/envkey","tags":["javascript","webpack","secrets","configuration","environment variables","security","encryption"],"install":[{"cmd":"npm install envkey-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add envkey-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add envkey-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin integration","package":"webpack","optional":false}],"imports":[{"note":"The package does not ship TypeScript declarations; CommonJS require is standard for webpack config files. ESM import may fail.","wrong":"import EnvkeyWebpackPlugin from 'envkey-webpack-plugin';","symbol":"EnvkeyWebpackPlugin","correct":"const EnvkeyWebpackPlugin = require('envkey-webpack-plugin');"},{"note":"CommonJS default export is the entire function/class; no named default export.","wrong":"const { default: EnvkeyWebpackPlugin } = require('envkey-webpack-plugin');","symbol":"default export","correct":"const EnvkeyWebpackPlugin = require('envkey-webpack-plugin');"},{"note":"The option key is 'permitted', not 'allowed' or 'allowlist'. 'dotEnvFile' is optional but defaults to loading .env. 'define' is optional.","wrong":"new EnvkeyWebpackPlugin({ allowed: ['VAR1'] })","symbol":"Constructor options","correct":"new EnvkeyWebpackPlugin({ permitted: ['VAR1'], dotEnvFile: '.env', define: { EXTRA: 'val' } })"}],"quickstart":{"code":"// webpack.config.js\nconst EnvkeyWebpackPlugin = require('envkey-webpack-plugin');\n\nmodule.exports = {\n  // ... other config\n  plugins: [\n    new EnvkeyWebpackPlugin({\n      permitted: ['API_URL', 'PUBLIC_KEY'],\n      dotEnvFile: '.env',\n      define: { ADDITIONAL: 'value' }\n    })\n  ]\n};","lang":"javascript","description":"Basic configuration of envkey-webpack-plugin with required permitted list and optional dotEnvFile and define options."},"warnings":[{"fix":"Explicitly list every variable you want available in the browser in the 'permitted' array. Do not rely on default behavior to include anything.","message":"All variables from EnvKey are injected into process.env, but only those in the 'permitted' list are allowed. Unlisted vars will be ignored.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to v2+ or pass ENVKEY via environment variable directly before webpack build.","message":"Old versions may not support the 'dotEnvFile' option. Always check compatibility with your webpack version.","severity":"deprecated","affected_versions":"<2.0"},{"fix":"Rebuild the application to pick up updated environment variable values. This is expected behavior for compile-time injection.","message":"The plugin only works at build time; variables are statically replaced via webpack's DefinePlugin. Runtime changes to EnvKey will not be reflected until a new build.","severity":"gotcha","affected_versions":"*"},{"fix":"If you want EnvKey values to take precedence, do not include them in 'define'. Check for naming conflicts.","message":"Using 'define' overrides variables with the same name from EnvKey. Order: EnvKey values are loaded first, then 'define' values overwrite them.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure your .env file has ENVKEY=... or set the ENVKEY environment variable in your CI/build system.","message":"The plugin requires a valid ENVKEY to be present either in the dotEnvFile or as an environment variable in the build process. Missing ENVKEY causes build failure.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install envkey-webpack-plugin --save-dev` in your project root.","cause":"Package not installed or not installed as dev dependency.","error":"Error: Cannot find module 'envkey-webpack-plugin'"},{"fix":"Use `const EnvkeyWebpackPlugin = require('envkey-webpack-plugin');` (CommonJS) instead of `import`.","cause":"Incorrect import (ESM default import in CommonJS context) or using an outdated version that exports differently.","error":"TypeError: EnvkeyWebpackPlugin is not a constructor"},{"fix":"Add ENVKEY=your_key to the .env file (or set it as an environment variable). Ensure the key is valid and not expired.","cause":"Missing or invalid ENVKEY in environment or .env file.","error":"Error: ENVKEY not found. Please set ENVKEY environment variable or include it in your dotenv file."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}