laurent22/joplin · error · Error

Cannot find "%s".

Error message

Cannot find "%s".

What it means

Thrown by `export <path> --note <note>` when `app().loadItems(ModelType.Note, args.options.note, { parent: app().currentFolder() })` returns an empty array. The lookup is scoped to the current notebook via the `parent` option, so a note that exists elsewhere is invisible here. loadItems resolves by exact title, full id, or partial id (>=2 chars); an empty result means none matched within the current folder.

Source

Thrown at packages/app-cli/app/command-export.ts:37

		const formats = service
			.modules()
			.filter(m => m.type === 'exporter' && m.format !== 'html')
			.map(m => m.format + (m.description ? ` (${m.description})` : ''));

		return [['--format <format>', _('Destination format: %s', formats.join(', '))], ['--note <note>', _('Exports only the given note.')], ['--notebook <notebook>', _('Exports only the given notebook.')]];
	}

	public override async action(args: { path: string; options: { format?: string; note?: string; 'notebook'?: string } }) {
		const exportOptions: ExportOptions = {};
		exportOptions.path = args.path;

		exportOptions.format = args.options.format ? args.options.format as ExportModuleOutputFormat : ExportModuleOutputFormat.Jex;

		if (exportOptions.format === 'html') throw new Error('HTML export is not supported. Please use the desktop application.');

		if (args.options.note) {
			const notes = await app().loadItems(ModelType.Note, args.options.note, { parent: app().currentFolder() });
			if (!notes.length) throw new Error(_('Cannot find "%s".', args.options.note));
			exportOptions.sourceNoteIds = notes.map(n => n.id);
		} else if (args.options.notebook) {
			const folders = await app().loadItems(ModelType.Folder, args.options.notebook);
			if (!folders.length) throw new Error(_('Cannot find "%s".', args.options.notebook));
			exportOptions.sourceFolderIds = folders.map(n => n.id);
		}

		const service = InteropService.instance();
		const result = await service.export(exportOptions);

		result.warnings.map(w => this.stdout(w));
	}
}

module.exports = Command;

View on GitHub (pinned to 2654b33620)

Solutions

  1. Run `joplin ls` and copy the exact title or full id of the target note
  2. Switch to the notebook containing the note first: `joplin use <notebook>`, then re-run export with `--note`
  3. Use the full note id rather than a partial id (<2 chars never resolves)
  4. If exporting regardless of notebook, use `--notebook <name>` instead and drop `--note`

Example fix

// before
joplin use WrongBook
joplin export out.md --note "Meeting"   // throws: Cannot find "Meeting".

// after
joplin use Work
joplin export out.md --note "Meeting"
// or export by id regardless of selection:
joplin export out.md --note <full-note-id>
Defensive patterns

Strategy: validation

Validate before calling

import app from './app';
import { ModelType } from '@joplin/lib/BaseModel';

async function resolveNoteForExport(noteRef: string) {
  if (!app().currentFolder()) throw new Error('Select a notebook first (`use <notebook>`).');
  const notes = await app().loadItems(ModelType.Note, noteRef, { parent: app().currentFolder() });
  if (!notes.length) throw new Error(`Cannot find "${noteRef}" in notebook "${app().currentFolder().title}". Use ls to verify.`);
  return notes;
}

// use this before building ExportOptions

Type guard

const hasNoteMatches = (notes: unknown[]): notes is { id: string }[] =>
  Array.isArray(notes) && notes.length > 0;

Try / catch

try {
  await cli.execCommand(['export', path, '--note', noteRef]);
} catch (e) {
  if (e.message.startsWith('Cannot find')) {
    // surface a helpful hint, retry with `use` or fall back to full export
    console.error(e.message, '— verify the note is in the current notebook.');
  } else throw e;
}

Prevention

When it happens

Trigger: Passing `--note` with a title that doesn't exist in the *current* notebook (it does exist in another); a typo; a partial id shorter than 2 chars; a note that was deleted or moved to trash; passing a note id when no notebook is selected and `currentFolder()` is null (loadItems throws a different error first).

Common situations: Exporting a note by title when the active notebook changed since `ls`; copy-paste of a note id with trailing whitespace; partial-id matches that are too short to be considered.

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/0f2a168af7b3e947. Report an issue: GitHub.