canirequire

canirequireESM-only › pnpm

Is pnpm ESM-only? Can you require() it?

Fast, disk space efficient package manager

Last verified Sep 9, 2026 against pnpm@12.3.4. JSON

ESM-only ESM-only since 12.0.0 — last CommonJS version is 11.26.0

pnpm dropped its CommonJS build in 12.0.0 (August 2026). The last version you can require() on every Node.js version, including 18 and older, is 11.26.0, published Sep 6, 2026.

require("pnpm") failed in our probe on Node.js 20+ as well. See the runtime matrix below for the exact error.

Latest
12.3.4 (Sep 4, 2026)
Module format
ESM-only
Last CommonJS version
11.26.0
ESM-only since
12.0.0 (Aug 26, 2026)
TypeScript types
None
Node engines
>=18.*
Weekly downloads
161.3M
License
MIT

Does pnpm@12.3.4 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("pnpm") from a CommonJS file and import "pnpm" from an ES module.

Runtimerequire("pnpm")import "pnpm"
Node.js 18✗ failsMODULE_NOT_FOUND✗ failsERR_MODULE_NOT_FOUND
Node.js 20✗ failsMODULE_NOT_FOUND✗ failsERR_MODULE_NOT_FOUND
Node.js 22✗ failsMODULE_NOT_FOUND✗ failsERR_MODULE_NOT_FOUND
Node.js 24✗ failsMODULE_NOT_FOUND✗ failsERR_MODULE_NOT_FOUND
Node.js 26✗ failsMODULE_NOT_FOUND✗ failsERR_MODULE_NOT_FOUND
Bun 1.4✗ failserror: Cannot find package 'pnpm' from '/Users/boat/Projects/top-seo/data/probe-work/pnpm/req.cjs'✗ failserror: Cannot find package 'pnpm' from '/Users/boat/Projects/top-seo/data/probe-work/pnpm/imp.mjs'

How to import pnpm

ES modules (import)

import pnpm from "pnpm";

CommonJS (require)

// Node.js 20.19+ / 22.12+ / newer (package has no top-level await):
const pnpm = require("pnpm");

// Any Node.js version:
const pnpm = await import("pnpm");

// Or pin the last CommonJS release:
// npm install pnpm@11.26.0

Module format by version

Derived from the type, main and exports fields of every stable release on npm (980 versions; the newest 60 shown).

VersionsFormatFirst published
12.0.0 – 12.4.0ESM-onlyAug 26, 2026
10.34.2 – 11.26.0CommonJSJun 10, 2026

Frequently asked

Is pnpm ESM-only?

pnpm@12.3.4 is ESM-only. pnpm dropped its CommonJS build in 12.0.0 (August 2026). The last version you can require() on every Node.js version, including 18 and older, is 11.26.0, published Sep 6, 2026.

Which version of pnpm still supports CommonJS / require()?

11.26.0 is the last version of pnpm with a CommonJS build. Install it with "npm install pnpm@11.26.0". Every version from 12.0.0 on is ESM-only.

How do I use pnpm from a CommonJS file?

Use a dynamic import: const mod = await import("pnpm"). On Node.js 20.19+, 22.12+ and newer, a plain require("pnpm") also works for ESM packages that do not use top-level await. Alternatively pin pnpm@11.26.0.

Does pnpm work in Bun?

Importing pnpm failed in Bun 1.4 on Sep 9, 2026: error: Cannot find package 'pnpm' from '/Users/boat/Projects/top-seo/data/probe-work/pnpm/imp.mjs'

Does pnpm ship TypeScript types?

No. pnpm ships no type declarations and there is no @types package for it.

Links

Other esm-only packages

Similar popularity