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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
axios publishes both a CommonJS entry and a native ESM entry (ESM added in 1.0.0). require("axios") and import "axios" both work on every supported Node.js version and in Bun.
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 | ✓ works | ✓ works |
How to import axios
ES modules (import)
import axios from "axios";CommonJS (require)
const axios = require("axios");Module format by version
Derived from the type, main and exports fields of every stable release on npm (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") and import "axios" both work on every supported Node.js version and in Bun.
Can I require axios?
Yes. axios ships a CommonJS entry, so require("axios") works on every Node.js version, alongside the native ESM entry for import.
Does axios work in Bun?
Yes. import "axios" loaded successfully in Bun 1.4 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
- 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
- kind-of 6.0.3CommonJS
- has-tostringtag 1.0.2CommonJS
- parse5 8.0.1ESM-only
- toidentifier 1.0.1CommonJS
- delayed-stream 1.0.0CommonJS
- imurmurhash 0.1.4CommonJS
- combined-stream 1.0.8CommonJS
- wrappy 1.0.2CommonJS