canirequire › Dual (CommonJS + ESM) › @radix-ui/primitive
Is @radix-ui/primitive ESM-only? Can you require() it?
Last verified Sep 9, 2026 against @radix-ui/primitive@1.1.7. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
@radix-ui/primitive publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.1). require("@radix-ui/primitive") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@radix-ui/primitive" works alongside it.
What to do
- Nothing to change. require("@radix-ui/primitive") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as primitive from "@radix-ui/primitive" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does @radix-ui/primitive@1.1.7 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@radix-ui/primitive") from a CommonJS file and import "@radix-ui/primitive" from an ES module.
| Runtime | require("@radix-ui/primitive") | import "@radix-ui/primitive" |
|---|---|---|
| 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.0 | ✓ works | ✓ works |
How to import @radix-ui/primitive
ES modules (import)
import * as primitive from "@radix-ui/primitive";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const primitive = require("@radix-ui/primitive");Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (16 versions; the newest 16 shown).
| Versions | Format | First published |
|---|---|---|
| 1.0.1 – 1.1.7 | Dual (CommonJS + ESM) | May 26, 2023 |
| 0.0.1 – 1.0.0 | CommonJS | Mar 3, 2021 |
Frequently asked
Is @radix-ui/primitive ESM-only?
@radix-ui/primitive@1.1.7 ships CommonJS and ESM builds. @radix-ui/primitive publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.1). require("@radix-ui/primitive") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@radix-ui/primitive" works alongside it.
Can I require @radix-ui/primitive?
Yes. @radix-ui/primitive ships a CommonJS entry alongside the native ESM entry. require("@radix-ui/primitive") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does @radix-ui/primitive work in Bun?
Yes. import "@radix-ui/primitive" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @radix-ui/primitive ship TypeScript types?
Yes. @radix-ui/primitive bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- d3-interpolate 3.0.1ESM-only
- jest-diff 30.5.1Dual
- @tailwindcss/node 4.3.3Dual
- get-east-asian-width 1.6.0ESM-only
- stop-iteration-iterator 1.1.0CommonJS
- data-uri-to-buffer 8.0.0ESM-only
- d3-format 3.1.2ESM-only
- reflect.getprototypeof 1.0.10CommonJS