canirequire

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

Latest
1.20.0 (Aug 26, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
1.20.0
Native ESM since
1.0.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
106.5M
License
MIT

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.

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

VersionsFormatFirst published
1.2.5 – 1.20.0Dual (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

Similar popularity