{"id":20849,"library":"webpack-validator","title":"webpack-validator","description":"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.","status":"maintenance","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/js-dxtools/webpack-validator","tags":["javascript","webpack","config","schema","validation","joi"],"install":[{"cmd":"npm install webpack-validator","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-validator","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-validator","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for schema validation of webpack configs","package":"joi","optional":false}],"imports":[{"note":"Default export is the main validate function. CommonJS require is also supported.","wrong":"const validate = require('webpack-validator').default;","symbol":"default","correct":"import validate from 'webpack-validator';"},{"note":"For array configs, use validateRoot instead of default.","wrong":"const validateRoot = require('webpack-validator').validateRoot;","symbol":"validateRoot","correct":"import { validateRoot } from 'webpack-validator';"},{"note":"Alias for default import, not commonly used.","wrong":null,"symbol":"webpackValidator","correct":"import webpackValidator from 'webpack-validator';"}],"quickstart":{"code":"// Install: npm install webpack-validator joi\n\nconst validate = require('webpack-validator');\n\n// Example webpack config with a subtle error (loaders should be an array of strings)\nconst config = {\n  entry: './app.js',\n  output: {\n    path: './dist',\n    filename: 'bundle.js'\n  },\n  module: {\n    loaders: [\n      { test: /\\.js$/, loader: 'babel-loader', exclude: /node_modules/ }\n    ]\n  }\n};\n\n// Validate the config - will throw/display errors if invalid\nconst validConfig = validate(config);\n\n// Webpack v1 users: place this in your webpack.config.js\nmodule.exports = validate({ /* your config */ });","lang":"javascript","description":"Shows how to import and use webpack-validator to validate a webpack v1 config, including an example with a common error."},"warnings":[{"fix":"Use webpack v1 or remove webpack-validator if using webpack v2+ (which has built-in validation).","message":"Version 3.0.0 throws an error when webpack 2 is installed alongside.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate to webpack v2+ and use its built-in validation, or continue using this package for webpack v1 only.","message":"The package is in maintenance mode and not actively developed. Webpack v2+ includes built-in config validation.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Provide a custom schema via the second argument to validate() or use the CLI --schema flag.","message":"The schema may not cover all custom webpack options (e.g., custom plugins). Use the '--schema' CLI option to extend.","severity":"gotcha","affected_versions":"all"},{"fix":"Use default export for single config, validateRoot for array configs.","message":"In v2.2.5, the exposed API changed (fix regression). Ensure you're using the correct export.","severity":"breaking","affected_versions":"2.2.5 - 2.2.12"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install joi' alongside webpack-validator.","cause":"joi is a peer dependency not automatically installed.","error":"Error: Cannot find module 'joi'"},{"fix":"Change 'loaders: \"babel-loader\"' to 'loaders: [\"babel-loader\"]'.","cause":"The 'loaders' property must be an array, but a string was provided.","error":"ValidationError: child \"module\" fails because [child \"loaders\" fails because [\"loaders\" must be an array]]"},{"fix":"Use 'const validate = require('webpack-validator');' without .default.","cause":"Using .default when requiring in CommonJS (common with ES6 interop).","error":"TypeError: validate is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}