redis / redis/node-redis

SyntaxError: Named export 'commandOptions' not found.

Open
#3,022 4 comments 3 reactions 1 assignee View on GitHub

@nkaradzhov is already working on this.

Since Jul 21, 2025.

Bug
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

Description

Hello!

I wrote a custom cache handler for a Next.js app. The only import i use is createClient:

import {createClient} from 'redis';

const client = createClient({
    url: process.env.REDIS_URL || 'redis://localhost:6379',
});

const result = await client
    .withCommandOptions({signal: AbortSignal.timeout(10000)})
    .get('key');

Even if i remove the .withCommandOptions(...) call, during the build i get the following error:

SyntaxError: Named export 'commandOptions' not found. The requested module 'redis' is a CommonJS module, which may not support all module.exports as named exports.
Node.js Version

20.15.1

Redis Server Version

7.2.4

Node Redis Version

5.6.0

Platform

Linux (WSL)

Logs
2025-07-18 17:28:56 > next build --experimental-build-mode generate && next start
2025-07-18 17:28:56 
2025-07-18 17:28:57 Attention: Next.js now collects completely anonymous telemetry regarding usage.
2025-07-18 17:28:57 This information is used to shape Next.js' roadmap and prioritize features.
2025-07-18 17:28:57 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
2025-07-18 17:28:57 https://nextjs.org/telemetry
2025-07-18 17:28:57 
2025-07-18 17:28:57    ▲ Next.js 15.1.6
2025-07-18 17:28:57    - Experiments (use with caution):
2025-07-18 17:28:57      · staleTimes
2025-07-18 17:28:57 
2025-07-18 17:28:57    Creating an optimized production build ...
2025-07-18 17:28:57    Collecting page data ...
2025-07-18 17:29:04 
2025-07-18 17:29:04 > Build error occurred
2025-07-18 17:29:04 [SyntaxError: Named export 'commandOptions' not found. The requested module 'redis' is a CommonJS module, which may not support all module.exports as named exports.
2025-07-18 17:29:04 CommonJS modules can always be imported via the default export, for example using:
2025-07-18 17:29:04 
2025-07-18 17:29:04 import pkg from 'redis';
2025-07-18 17:29:04 const { commandOptions } = pkg;
2025-07-18 17:29:04 ] {
2025-07-18 17:29:04   type: 'SyntaxError'
2025-07-18 17:29:04 }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.