canirequire › Dual (CommonJS + ESM) › chart.js
Is chart.js ESM-only? Can you require() it?
Simple HTML5 charts using the canvas element.
Last verified Sep 9, 2026 against chart.js@4.5.1. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
chart.js publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.1). require("chart.js") and import "chart.js" both work on every supported Node.js version and in Bun.
Does chart.js@4.5.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("chart.js") from a CommonJS file and import "chart.js" from an ES module.
| Runtime | require("chart.js") | import "chart.js" |
|---|---|---|
| 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 chart.js
ES modules (import)
import chartJs from "chart.js";CommonJS (require)
const chartJs = require("chart.js");Module format by version
Derived from the type, main and exports fields of every stable release on npm (77 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 4.1.0 – 4.5.1 | Dual (CommonJS + ESM) | Dec 16, 2022 |
| 4.0.1 | ESM-only | Nov 14, 2022 |
| 2.3.0 – 3.9.1 | CommonJS | Sep 22, 2016 |
Frequently asked
Is chart.js ESM-only?
chart.js@4.5.1 ships CommonJS and ESM builds. chart.js publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.1). require("chart.js") and import "chart.js" both work on every supported Node.js version and in Bun.
Can I require chart.js?
Yes. chart.js ships a CommonJS entry, so require("chart.js") works on every Node.js version, alongside the native ESM entry for import.
Does chart.js work in Bun?
Yes. import "chart.js" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does chart.js ship TypeScript types?
Yes. chart.js 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
- webpack-dev-server 6.0.0Dual
- del 8.0.1ESM-only
- tiny-warning 1.0.3CommonJS
- class-transformer 0.5.1CommonJS
- source-map-loader 5.0.0CommonJS
- yup 1.7.1CommonJS
- mysql2 3.24.4CommonJS
- class-validator 0.15.1CommonJS