canirequire › Dual (CommonJS + ESM) › axios
Is axios ESM-only? Can you require() it?
Promise based HTTP client for the browser and node.js
Last verified Sep 9, 2026 against axios@1.20.0. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
axios publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.0). require("axios") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "axios" works alongside it.
What to do
- Nothing to change. require("axios") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as axios from "axios" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does axios@1.20.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("axios") from a CommonJS file and import "axios" from an ES module.
| Runtime | require("axios") | import "axios" |
|---|---|---|
| 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.0 | ✓ works | ✓ works |
How to import axios
ES modules (import)
import * as axios from "axios";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const axios = require("axios");Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (137 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 1.2.5 – 1.20.0 | Dual (CommonJS + ESM) | Jan 26, 2023 |
Frequently asked
Is axios ESM-only?
axios@1.20.0 ships CommonJS and ESM builds. axios publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.0). require("axios") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "axios" works alongside it.
Can I require axios?
Yes. axios ships a CommonJS entry alongside the native ESM entry. require("axios") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does axios work in Bun?
Yes. import "axios" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does axios ship TypeScript types?
Yes. axios 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
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- has-tostringtag 1.0.2CommonJS
- @vitest/expect 5.0.0ESM-only
- parse5 8.0.1ESM-only
- toidentifier 1.0.1CommonJS
- delayed-stream 1.0.0CommonJS
- imurmurhash 0.1.4CommonJS
- @eslint/core 1.2.1No entry
- combined-stream 1.0.8CommonJS