canirequire › ESM-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.
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.
| Runtime | require("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.0Module format by version
Derived from the type, main and exports fields of every stable release on npm (111 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 8.0.0 – 12.1.0 | ESM-only | May 27, 2023 |
| 5.1.0 – 7.7.0 | CommonJS | Sep 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
- ansi-styles 7.0.0last CJS
5.2.0 - strip-ansi 7.2.0last CJS
6.0.1 - commander 15.0.0last CJS
14.0.3 - supports-color 11.0.0last CJS
8.1.1 - chalk 6.0.0last CJS
4.1.2 - tslib 2.8.1last CJS
2.5.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1
Similar popularity
- rollup-plugin-replace 2.2.0CommonJS
- yeoman-test 11.8.2Dual
- xo 4.0.0ESM-only
- gulp-watch 5.0.1CommonJS
- ember-data 5.9.1CommonJS
- vinyl-source-stream 2.0.0CommonJS
- gulp-istanbul 1.1.3CommonJS
- gulp-eslint 6.0.0CommonJS