canirequire › Dual (CommonJS + ESM) › package-json-from-dist
Is package-json-from-dist ESM-only? Can you require() it?
Load the local package.json from either src or dist folder
Last verified Sep 9, 2026 against package-json-from-dist@1.0.1. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
package-json-from-dist publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.0). require("package-json-from-dist") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "package-json-from-dist" works alongside it.
What to do
- Nothing to change. require("package-json-from-dist") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as packageJsonFromDist from "package-json-from-dist" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does package-json-from-dist@1.0.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("package-json-from-dist") from a CommonJS file and import "package-json-from-dist" from an ES module.
| Runtime | require("package-json-from-dist") | import "package-json-from-dist" |
|---|---|---|
| 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 package-json-from-dist
ES modules (import)
import * as packageJsonFromDist from "package-json-from-dist";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const packageJsonFromDist = require("package-json-from-dist");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 (2 versions; the newest 2 shown).
| Versions | Format | First published |
|---|---|---|
| 1.0.0 – 1.0.1 | Dual (CommonJS + ESM) | May 14, 2024 |
Frequently asked
Is package-json-from-dist ESM-only?
package-json-from-dist@1.0.1 ships CommonJS and ESM builds. package-json-from-dist publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.0). require("package-json-from-dist") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "package-json-from-dist" works alongside it.
Can I require package-json-from-dist?
Yes. package-json-from-dist ships a CommonJS entry alongside the native ESM entry. require("package-json-from-dist") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does package-json-from-dist work in Bun?
Yes. import "package-json-from-dist" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does package-json-from-dist ship TypeScript types?
Yes. package-json-from-dist 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
- file-type 22.0.2ESM-only
- cli-spinners 3.4.0ESM-only
- process 0.11.10CommonJS
- @radix-ui/react-progress 1.1.16Dual
- terser-webpack-plugin 5.6.1CommonJS
- @radix-ui/react-scroll-area 1.2.18Dual
- glob-to-regexp 0.4.1CommonJS
- @hookform/resolvers 5.9.1Dual