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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
expressJoi
✓ const expressJoi = require('express-joi-validator');
✗ import expressJoi from 'express-joi-validator';
Plugin uses CommonJS and has no default ESM export; dynamic import is possible but not the default.
default
✓ const expressJoi = require('express-joi-validator');
✗ import * as expressJoi from 'express-joi-validator';
Module exports a single function; namespace import won't work correctly.
validate
✓ const { validate } = require('express-joi-validator');
✗ const validate = require('express-joi-validator').validate;
No named export 'validate' exists; the main export is the middleware function itself.
Express server with GET and POST routes using express-joi-validator for query and body validation.
const express = require('express');
const bodyParser = require('body-parser');
const expressJoi = require('express-joi-validator');
const Joi = require('joi');
const app = express();
app.use(bodyParser.json());
const querySchema = {
query: {
limit: Joi.number().default(10).min(10).max(100),
offset: Joi.number().default(10).min(10).max(100)
}
};
app.get('/', expressJoi(querySchema), (req, res) => {
res.json({ limit: req.query.limit, offset: req.query.offset });
});
const bodySchema = {
body: {
name: Joi.string().required()
}
};
app.post('/', expressJoi(bodySchema), (req, res) => {
res.json({ name: req.body.name });
});
app.use((err, req, res, next) => {
if (err.isBoom) {
return res.status(err.output.statusCode).json(err.output.payload);
}
next(err);
});
app.listen(8080);
Errors
Common errors & fixes
Cannot find module 'joi'
joi is a peer dependency and not automatically installed.
fixRun: npm install joi@6.x.x
err.isBoom is not a function
Error object is a Boom error from joi, but code tries to call it as a function.
fixCheck err.isBoom as a boolean property, not a method: if (err.isBoom) { ... } req.body is undefined
Missing body-parser middleware before validation.
fixAdd app.use(bodyParser.json()) before routes.
Audit
Dependencies
joirequiredPeer dependency required for validation schemas