canirequire › Dual (CommonJS + ESM) › web-vitals
Is web-vitals ESM-only? Can you require() it?
Easily measure performance metrics in JavaScript
Last verified Sep 9, 2026 against web-vitals@6.2.1. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
web-vitals publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.0). require("web-vitals") and import "web-vitals" both work on every supported Node.js version and in Bun.
Does web-vitals@6.2.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("web-vitals") from a CommonJS file and import "web-vitals" from an ES module.
| Runtime | require("web-vitals") | import "web-vitals" |
|---|---|---|
| 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 web-vitals
ES modules (import)
import webVitals from "web-vitals";CommonJS (require)
const webVitals = require("web-vitals");Module format by version
Derived from the type, main and exports fields of every stable release on npm (54 versions; the newest 54 shown).
| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 6.2.1 | Dual (CommonJS + ESM) | Aug 24, 2022 |
| 0.2.2 – 2.1.4 | CommonJS | May 12, 2020 |
| 0.1.0 – 0.2.1 | ESM-only | Apr 24, 2020 |
Frequently asked
Is web-vitals ESM-only?
web-vitals@6.2.1 ships CommonJS and ESM builds. web-vitals publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.0). require("web-vitals") and import "web-vitals" both work on every supported Node.js version and in Bun.
Can I require web-vitals?
Yes. web-vitals ships a CommonJS entry, so require("web-vitals") works on every Node.js version, alongside the native ESM entry for import.
Does web-vitals work in Bun?
Yes. import "web-vitals" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does web-vitals ship TypeScript types?
Yes. web-vitals bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- is-buffer 2.0.5CommonJS
- cli-truncate 6.1.1ESM-only
- @smithy/property-provider 4.5.2CommonJS
- immediate 3.3.0CommonJS
- react-transition-group 4.4.5CommonJS
- postcss-nested 8.0.1ESM-only
- dlv 1.1.3CommonJS
- cacache 21.0.1CommonJS