canirequire

canirequireDual (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.

Latest
6.2.1 (Aug 26, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
6.2.1
Native ESM since
0.1.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
35.8M
License
Apache-2.0

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.

Runtimerequire("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).

VersionsFormatFirst published
3.0.0 – 6.2.1Dual (CommonJS + ESM)Aug 24, 2022
0.2.2 – 2.1.4CommonJSMay 12, 2020
0.1.0 – 0.2.1ESM-onlyApr 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

Similar popularity