canirequire

canirequireCommonJS › doctrine

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

JSDoc parser

Last verified Sep 9, 2026 against doctrine@3.0.0. JSON

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

doctrine ships CommonJS only. require("doctrine") works everywhere. import "doctrine" 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
3.0.0 (Nov 10, 2018)
Module format
CommonJS
Last CommonJS version
3.0.0
TypeScript types
@types/doctrine
Node engines
>=6.0.0
Weekly downloads
112.0M
License
Apache-2.0

Does doctrine@3.0.0 actually load? Runtime test results

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

Runtimerequire("doctrine")import "doctrine"
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 doctrine

ES modules (import)

import doctrine from "doctrine";

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 doctrine = require("doctrine");

Module format by version

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

VersionsFormatFirst published
0.0.1 – 3.0.0CommonJSMay 10, 2012

Frequently asked

Is doctrine ESM-only?

doctrine@3.0.0 is a CommonJS package. doctrine ships CommonJS only. require("doctrine") works everywhere. import "doctrine" 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 doctrine with ES module syntax?

Yes. import doctrine from "doctrine" 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 doctrine work in Bun?

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

Does doctrine ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/doctrine".

Links

Other commonjs packages

Similar popularity