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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
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") and import "package-json-from-dist" both work on every supported Node.js version and in Bun.
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 | ✓ works | ✓ works |
How to import package-json-from-dist
ES modules (import)
import packageJsonFromDist from "package-json-from-dist";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 (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") and import "package-json-from-dist" both work on every supported Node.js version and in Bun.
Can I require package-json-from-dist?
Yes. package-json-from-dist ships a CommonJS entry, so require("package-json-from-dist") works on every Node.js version, alongside the native ESM entry for import.
Does package-json-from-dist work in Bun?
Yes. import "package-json-from-dist" loaded successfully in Bun 1.4 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
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- @aws-sdk/middleware-host-header 3.972.45CommonJS
- file-type 22.0.2ESM-only
- cli-spinners 3.4.0ESM-only
- process 0.11.10CommonJS
- terser-webpack-plugin 5.6.1CommonJS
- glob-to-regexp 0.4.1CommonJS
- @hookform/resolvers 5.9.1Dual
- bluebird 3.7.2CommonJS