canirequire

canirequireESM-only › np

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

A better `npm publish`

Last verified Sep 9, 2026 against np@12.1.0. JSON

ESM-only ESM-only since 8.0.0 — last CommonJS version is 7.7.0

np dropped its CommonJS build in 8.0.0 (May 2023). The last version you can require() on every Node.js version, including 18 and older, is 7.7.0, published Mar 30, 2023.

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

np@12.1.0 declares engines ">=22", so Node.js 18, 20 are outside its supported range regardless of module format.

Latest
12.1.0 (Sep 1, 2026)
Module format
ESM-only
Last CommonJS version
7.7.0
ESM-only since
8.0.0 (May 27, 2023)
TypeScript types
None
Node engines
>=22
Weekly downloads
134K
License
MIT

Does np@12.1.0 actually load? Runtime test results

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

Runtimerequire("np")import "np"
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 'np' from '/Users/boat/Projects/top-seo/data/probe-work/np/req.cjs'✗ failserror: Cannot find package 'np' from '/Users/boat/Projects/top-seo/data/probe-work/np/imp.mjs'

How to import np

ES modules (import)

import np from "np";

CommonJS (require)

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

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

// Or pin the last CommonJS release:
// npm install np@7.7.0

Module format by version

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

VersionsFormatFirst published
8.0.0 – 12.1.0ESM-onlyMay 27, 2023
5.1.0 – 7.7.0CommonJSSep 13, 2019

Frequently asked

Is np ESM-only?

np@12.1.0 is ESM-only. np dropped its CommonJS build in 8.0.0 (May 2023). The last version you can require() on every Node.js version, including 18 and older, is 7.7.0, published Mar 30, 2023.

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

7.7.0 is the last version of np with a CommonJS build. Install it with "npm install np@7.7.0". Every version from 8.0.0 on is ESM-only.

How do I use np from a CommonJS file?

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

Does np work in Bun?

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

Does np ship TypeScript types?

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

Links

Other esm-only packages

Similar popularity