# Is package-json-from-dist ESM-only? Can you require() it?

> package-json-from-dist@1.0.1 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Load the local package.json from either src or dist folder

Last verified Sep 9, 2026 against package-json-from-dist@1.0.1.

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

1. 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.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- 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

## Runtime test results for package-json-from-dist@1.0.1

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:

```js
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:

```js
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") 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

- [package-json-from-dist on npm](https://www.npmjs.com/package/package-json-from-dist)
- [Source repository](https://github.com/isaacs/package-json-from-dist)
- [HTML version](https://canirequire.com/package/package-json-from-dist/)
- [JSON version](https://canirequire.com/package/package-json-from-dist.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
