Registry / devops / webpack-validator

webpack-validator

JSON →
library3.0.1jsnpmunverified

Validate your webpack configs using joi schema. Provides static type checking, spell checking, and semantic validations (e.g., preventing simultaneous use of loader and loaders). Current stable version is 3.0.1. The package is in maintenance mode: webpack v2+ has built-in validation, so this package only supports webpack v1. Last update in 2017, with no active development. Key differentiator: it catches errors like misspelled loader names or incorrect plugin usage via a schema-based validation.

npm install webpack-validator
INSTALL
IMPORT
SIG · WEBPACK-VALIDATOR
W
webpack-validator
devopsjavascriptv3.0.1
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import validate from 'webpack-validator';
const validate = require('webpack-validator').default;
Default export is the main validate function. CommonJS require is also supported.
validateRoot
import { validateRoot } from 'webpack-validator';
const validateRoot = require('webpack-validator').validateRoot;
For array configs, use validateRoot instead of default.
webpackValidator
import webpackValidator from 'webpack-validator';
Alias for default import, not commonly used.

Shows how to import and use webpack-validator to validate a webpack v1 config, including an example with a common error.

// Install: npm install webpack-validator joi const validate = require('webpack-validator'); // Example webpack config with a subtle error (loaders should be an array of strings) const config = { entry: './app.js', output: { path: './dist', filename: 'bundle.js' }, module: { loaders: [ { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ } ] } }; // Validate the config - will throw/display errors if invalid const validConfig = validate(config); // Webpack v1 users: place this in your webpack.config.js module.exports = validate({ /* your config */ });
Debug
Known issues
breakingVersion 3.0.0 throws an error when webpack 2 is installed alongside.
fix
Use webpack v1 or remove webpack-validator if using webpack v2+ (which has built-in validation).
affects: >=3.0.0
deprecatedThe package is in maintenance mode and not actively developed. Webpack v2+ includes built-in config validation.
fix
Migrate to webpack v2+ and use its built-in validation, or continue using this package for webpack v1 only.
affects: >=2.0.0
gotchaThe schema may not cover all custom webpack options (e.g., custom plugins). Use the '--schema' CLI option to extend.
fix
Provide a custom schema via the second argument to validate() or use the CLI --schema flag.
affects: all
breakingIn v2.2.5, the exposed API changed (fix regression). Ensure you're using the correct export.
fix
Use default export for single config, validateRoot for array configs.
affects: 2.2.5 - 2.2.12
Errors
Common errors & fixes
Error: Cannot find module 'joi'
joi is a peer dependency not automatically installed.
fix
Run 'npm install joi' alongside webpack-validator.
ValidationError: child "module" fails because [child "loaders" fails because ["loaders" must be an array]]
The 'loaders' property must be an array, but a string was provided.
fix
Change 'loaders: "babel-loader"' to 'loaders: ["babel-loader"]'.
TypeError: validate is not a function
Using .default when requiring in CommonJS (common with ES6 interop).
fix
Use 'const validate = require('webpack-validator');' without .default.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
joirequiredUsed for schema validation of webpack configs
Agent activity
14 hits · last 30 days
node
12
Resources
webpack-validator — npm install webpack-validator · libregistry