canirequire

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

Latest
4.5.1 (Oct 13, 2025)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
4.5.1
Native ESM since
4.0.1
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
11.2M
License
MIT

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.

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

VersionsFormatFirst published
4.1.0 – 4.5.1Dual (CommonJS + ESM)Dec 16, 2022
4.0.1ESM-onlyNov 14, 2022
2.3.0 – 3.9.1CommonJSSep 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

Similar popularity