Registry / devops / node-env-webpack-plugin

node-env-webpack-plugin

JSON →
library2.0.0jsnpmunverified

Simplifies NODE_ENV handling in webpack builds. Current stable version 2.0.0 (2024), requires Node.js >=18 and is pure ESM. Sets process.env.NODE_ENV automatically: defaults to 'development' at import time if undefined, or 'production' when webpack runs with -p. Provides convenience boolean getters (isProduction, isDevelopment, isTest) to avoid typos, and a devtool helper that selects source-map in production and cheap-module-source-map in development. Replaces manual NODE_ENV checks and webpack.EnvironmentPlugin setup with a single plugin.

npm install node-env-webpack-plugin
INSTALL
IMPORT
SIG · NODE-ENV-WEBPACK-P
N
node-env-webpack-plugin
devopsjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

NodeEnvPlugin
import NodeEnvPlugin from 'node-env-webpack-plugin'
const NodeEnvPlugin = require('node-env-webpack-plugin')
v2.0.0 is pure ESM; cannot use require().
NodeEnvPlugin.isProduction
import NodeEnvPlugin from 'node-env-webpack-plugin'; NodeEnvPlugin.isProduction
import { isProduction } from 'node-env-webpack-plugin'
isProduction is a static property of the default export, not a named export.
NodeEnvPlugin.devtool
import NodeEnvPlugin from 'node-env-webpack-plugin'; NodeEnvPlugin.devtool
const { devtool } = require('node-env-webpack-plugin')
devtool is a static property; destructuring only works with ESM named exports (not available here).

Minimal webpack config using NodeEnvPlugin to auto-set NODE_ENV and configure devtool based on environment.

// webpack.config.js import NodeEnvPlugin from 'node-env-webpack-plugin'; export default { entry: './src/index.js', output: { filename: 'bundle.js' }, devtool: NodeEnvPlugin.devtool, plugins: [ new NodeEnvPlugin() ] };
Debug
Known issues
breakingv2.0.0 dropped support for Node.js <18 and is now pure ESM. CommonJS require() will throw.
fix
Use import instead of require, and ensure Node.js >=18.
affects: >=2.0.0
breakingv2.0.0 stopped supporting webpack <5. The plugin only works with webpack 5+.
fix
Upgrade to webpack 5.
affects: >=2.0.0
gotchaNODE_ENV is set at import time, not when the plugin is instantiated. If you import the plugin but then change process.env.NODE_ENV before webpack processes the config, the plugin's static properties are based on the initial value.
fix
Set NODE_ENV before importing the plugin or use explicit webpack mode.
affects: >=1.0.0
gotchaThe plugin does not override NODE_ENV if it's already set. It only sets it when undefined at import time.
fix
If you need to force a specific NODE_ENV, set it explicitly in the environment.
affects: >=1.0.0
Errors
Common errors & fixes
require() of ES Module ... from ... not supported
Using CommonJS require() on an ESM-only package.
fix
Switch to import syntax (import NodeEnvPlugin from 'node-env-webpack-plugin') or use dynamic import() if needed.
Cannot find module 'node-env-webpack-plugin'
The package is not installed or Node.js version is <18 (v2 requires Node.js 18).
fix
Run 'npm install node-env-webpack-plugin' and ensure Node.js >=18.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-env-webpack-plugin — npm install node-env-webpack-plugin · libregistry