slidevjs/slidev · error · Error

[Slidev] ogImage: ${filename} not found

Error message

[Slidev] ogImage: ${filename} not found

What it means

During slidev build, if the configured ogImage file does not exist on disk and is not eligible for auto-generation (or generation produced no PNG), the build throws. Auto-generation only runs for ogImage paths ending in .png under the public-output flow.

Source

Thrown at packages/slidev/node/commands/build.ts:124

        timeout: args.timeout || 30000,
        perSlide: true,
        omitBackground: false,
        dark: args.dark,
      })

      const tempFiles = await fs.readdir(tempDir)
      const pngFile = tempFiles.find(file => file.endsWith('.png'))
      if (pngFile) {
        const generatedPath = resolve(tempDir, pngFile)
        await fs.copyFile(generatedPath, projectOgImagePath)
        await fs.copyFile(generatedPath, outputOgImagePath)
      }

      await fs.rm(tempDir, { recursive: true, force: true })
      server.close()
    }
    else {
      throw new Error(`[Slidev] ogImage: ${filename} not found`)
    }
  }

  // copy index.html to 404.html for GitHub Pages
  await fs.copyFile(resolve(outDir, 'index.html'), resolve(outDir, '404.html'))
  // _redirects for SPA
  const redirectsPath = resolve(outDir, '_redirects')
  if (!existsSync(redirectsPath))
    await fs.writeFile(redirectsPath, `${config.base}*    ${config.base}index.html   200\n`, 'utf-8')

  if ([true, 'true', 'auto'].includes(options.data.config.download)) {
    const { exportSlides, getExportOptions } = await import('./export')

    const port = 12445
    const app = connect()
    const server = http.createServer(app)
    app.use(
      config.base,

View on GitHub (pinned to 0d798ace58)

Solutions

  1. Provide a real ogImage file at the configured path
  2. Remove the ogImage setting if none is needed
  3. Ensure the path ends in .png so the auto-generation branch runs
  4. Install playwright-chromium so the generation step can succeed

Example fix

// before
ogImage: ./missing.png
// after
ogImage: ./public/og.png  (file exists)
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs'
if (config.ogImage) {
  const ogPath = resolve(publicDir, config.ogImage)
  if (!existsSync(ogPath) && !ogPath.endsWith('.png')) {
    throw new Error(`ogImage file not found and not auto-generatable: ${config.ogImage}`)
  }
}

Prevention

When it happens

Trigger: Setting ogImage: './missing.png' (or any non-existent image) where the file is absent and the .png auto-generation path did not produce a file.

Common situations: Deleting the referenced ogImage, relative-path typos, ogImage extension other than .png (no auto-gen), or upstream Playwright/render failure during generation.

Related errors


AI-assisted analysis of slidevjs/slidev@0d798ace58 (2026-08-12). Data as JSON: /api/errors/6e02c475df909736. Report an issue: GitHub.