facebook/docusaurus · error

No files to copy from path=${fromPath} with glob code=${glob

Error message

No files to copy from path=${fromPath} with glob code=${globPatternPosix}

What it means

Thrown inside `eject()` (the swizzle eject action) when Globby returns zero files for the resolved component path/glob. The code itself flags this as 'should never happen' — it indicates the resolved theme path did not contain the expected source files after applying the ignore rules.

Source

Thrown at packages/docusaurus/src/commands/swizzle/actions.ts:82

  const filesToCopy = await Globby(globPatternPosix, {
    // Workaround for Tinyglobby bug?
    // We glob absolute from the theme root path, not from cwd
    // See https://github.com/SuperchupuDev/tinyglobby/issues/186
    cwd: themePath,
    absolute: true,

    ignore: _.compact([
      '**/*.{story,stories,test,tests}.{js,jsx,ts,tsx}',
      // When ejecting JS components, we want to avoid emitting TS files
      // In particular the .d.ts files that theme build output contains
      typescript ? null : '**/*.{d.ts,ts,tsx}',
      '**/{__fixtures__,__tests__}/*',
    ]),
  });

  if (filesToCopy.length === 0) {
    // This should never happen
    throw new Error(
      logger.interpolate`No files to copy from path=${fromPath} with glob code=${globPatternPosix}`,
    );
  }

  const toPath = path.join(siteDir, THEME_PATH);

  await fs.ensureDir(toPath);

  const createdFiles = await Promise.all(
    filesToCopy.map(async (sourceFile: string) => {
      const targetFile = path.join(
        toPath,
        path.relative(themePath, sourceFile),
      );
      try {
        const fileContents = await fs.readFile(sourceFile, 'utf-8');
        await fs.outputFile(
          targetFile,

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Reinstall node_modules: `rm -rf node_modules && pnpm install` (or npm/yarn equivalent) to restore missing theme files.
  2. Retry without the language flag (e.g. drop `--javascript`) so the ignore filters do not strip all files.
  3. Confirm the component name is valid: run `docusaurus swizzle <theme> --list` and copy the exact name.
  4. Check the resolved theme path actually contains the file: `ls <themePath>/<component>` and inspect what Globby would match.

Example fix

# before
docusaurus swizzle @docusaurus/theme-classic NotFound --eject --javascript  # 0 files
# after
rm -rf node_modules && pnpm install
docusaurus swizzle @docusaurus/theme-classic NotFound --eject
Defensive patterns

Strategy: validation

Validate before calling

import {Globby, posixPath} from '@docusaurus/utils';
const files = await Globby(posixPath(globPattern), {cwd: themePath, absolute: true});
if (files.length === 0) throw new Error('Theme path empty — reinstall the theme package');

Try / catch

try { await eject({siteDir, themePath, componentName, typescript}); }
catch (e) {
  if (/No files to copy/.test(e.message)) {
    console.error('Reinstall node_modules and retry without language flags'); process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `docusaurus swizzle <theme> <component> --eject` where the computed `fromPath` plus the JS/TS-aware ignore patterns produces no matches. Triggered when the theme package is corrupt, the component path resolves to nothing, or the `--typescript`/JS filter excludes every file.

Common situations: Corrupted or partial theme package install (missing files); passing `--javascript` against a TS-only component whose compiled JS was stripped; pnpm hoisting placing the theme path elsewhere; mismatched theme version where a component was removed.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/ad647b0d760a836c. Report an issue: GitHub.