canirequire

canirequireCommonJS › express-session

Is express-session ESM-only? Can you require() it?

Simple session middleware for Express

Last verified Sep 9, 2026 against express-session@1.19.0. JSON

CommonJS CommonJS — require() works on every Node.js version

express-session ships CommonJS only. require("express-session") works everywhere. import "express-session" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
1.19.0 (Jan 22, 2026)
Module format
CommonJS
Last CommonJS version
1.19.0
TypeScript types
@types/express-session
Node engines
>= 0.8.0
Weekly downloads
3.8M
License
MIT

Does express-session@1.19.0 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("express-session") from a CommonJS file and import "express-session" from an ES module.

Runtimerequire("express-session")import "express-session"
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 express-session

ES modules (import)

import expressSession from "express-session";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const expressSession = require("express-session");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (67 versions; the newest 60 shown).

VersionsFormatFirst published
1.2.1 – 1.19.0CommonJSMay 27, 2014

Frequently asked

Is express-session ESM-only?

express-session@1.19.0 is a CommonJS package. express-session ships CommonJS only. require("express-session") works everywhere. import "express-session" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import express-session with ES module syntax?

Yes. import expressSession from "express-session" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does express-session work in Bun?

Yes. import "express-session" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does express-session ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/express-session".

Links

Other commonjs packages

Similar popularity