canirequire

canirequireCommonJS › joi

Is joi ESM-only? Can you require() it?

Object schema validation

Last verified Sep 9, 2026 against joi@18.2.8. JSON

CommonJS CommonJS — require() works on every Node.js version

joi ships CommonJS only. require("joi") works everywhere. import "joi" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
18.2.8 (Sep 2, 2026)
Module format
CommonJS
Last CommonJS version
18.2.8
TypeScript types
Bundled
Node engines
>= 20
Weekly downloads
24.2M
License
BSD-3-Clause

Does joi@18.2.8 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("joi") from a CommonJS file and import "joi" from an ES module.

Runtimerequire("joi")import "joi"
Node.js 18✓ works✓ works
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

How to import joi

ES modules (import)

import joi from "joi";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const joi = require("joi");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (246 versions; the newest 60 shown).

VersionsFormatFirst published
14.1.1 – 18.2.8CommonJSNov 24, 2018

Frequently asked

Is joi ESM-only?

joi@18.2.8 is a CommonJS package. joi ships CommonJS only. require("joi") works everywhere. import "joi" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import joi with ES module syntax?

Yes. import joi from "joi" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does joi work in Bun?

Yes. import "joi" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does joi ship TypeScript types?

Yes. joi bundles its own type declarations; no @types package is needed.

Links

Other commonjs packages

Similar popularity