canirequire

canirequireDual (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.

Latest
1.0.1 (Sep 26, 2024)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
1.0.1
Native ESM since
1.0.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
40.2M
License
BlueOak-1.0.0

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.

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

VersionsFormatFirst published
1.0.0 – 1.0.1Dual (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

Similar popularity