redis/node-redis · error · Error

Config file not found at path: ${path}

Error message

Config file not found at path: ${path}

What it means

loadFromFile reads a file via fs/promises.readFile and calls loadFromJson on its contents. When readFile rejects with code ENOENT (file does not exist), this error is thrown, naming the path. Any other read error (permissions, etc.) or a JSON parse error propagates as-is.

Source

Thrown at packages/test-utils/lib/cae-client-testing.ts:26

}

export type RedisEndpointsConfig = Record<string, RawRedisEndpoint>;

export function loadFromJson(jsonString: string): RedisEndpointsConfig {
  try {
    return JSON.parse(jsonString) as RedisEndpointsConfig;
  } catch (error) {
    throw new Error(`Invalid JSON configuration: ${error}`);
  }
}

export async function loadFromFile(path: string): Promise<RedisEndpointsConfig> {
  try {
    const configFile = await readFile(path, 'utf-8');
    return loadFromJson(configFile);
  } catch (error) {
    if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
      throw new Error(`Config file not found at path: ${path}`);
    }
    throw error;
  }
}

View on GitHub (pinned to 90fd0652bc)

Solutions

  1. Verify the path with an absolute path first to rule out working-directory issues
  2. Check the file exists before calling: await fs.access(path) — or create it
  3. Print path.resolve(process.cwd(), path) to confirm where Node is actually looking

Example fix

// before
const cfg = await loadFromFile('./redis-endpoints.json'); // ENOENT

// after
const { resolve } = require('node:path');
const p = resolve(__dirname, 'redis-endpoints.json');
await fs.access(p); // throws clearly if missing
const cfg = await loadFromFile(p);
Defensive patterns

Strategy: validation

Validate before calling

import { access } from 'node:fs/promises';
async function safeLoadFromFile(path: string) {
  await access(path); // throws ENOENT clearly if missing
  return loadFromFile(path);
}

Try / catch

try {
  const cfg = await loadFromFile(path);
} catch (e) {
  if (e instanceof Error && /Config file not found/.test(e.message)) {
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling loadFromFile(path) where path points to a non-existent file; passing a relative path resolved against an unexpected working directory; typo in the filename.

Common situations: Wrong working directory when running tests; config file committed to a different location; path built from an env var that is unset (yielding 'undefined' in the string); case-sensitivity mismatch on Linux.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/19fb5b098c9dfb90. Report an issue: GitHub.