apify/crawlee · error · Error
The project name cannot be empty string.
Error message
The project name cannot be empty string.
What it means
The Crawlee CLI `create` command validates the project name before scaffolding and rejects an empty string, since templates need a non-empty name for the directory and package name substitution.
Source
Thrown at packages/cli/src/commands/CreateProjectCommand.ts:21
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { get } from 'node:https';
import { dirname, join, resolve } from 'node:path';
import { setTimeout } from 'node:timers/promises';
import type { Template } from '@crawlee/templates';
import { fetchManifest } from '@crawlee/templates';
import { input, select } from '@inquirer/prompts';
import colors from 'ansi-colors';
import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
interface CreateProjectArgs {
projectName?: string;
template?: string;
}
function validateProjectName(name: string) {
if (name.length === 0) {
throw new Error('The project name cannot be empty string.');
}
}
async function rewrite(path: string, replacer: (from: string) => string) {
try {
const file = await readFile(path, 'utf8');
const replaced = replacer(file);
await writeFile(path, replaced);
} catch {
// not found
}
}
async function withRetries<F extends (...args: unknown[]) => unknown>(
func: F,
retries: number,
label: string,
): Promise<Awaited<ReturnType<F>>> {View on GitHub (pinned to dbe57fb09c)
Solutions
- Pass a non-empty project name to the create command.
- In scripts, validate `${PROJECT_NAME}` is non-empty before invoking the CLI.
- Omit the name argument entirely to let the CLI prompt interactively.
Example fix
# before
npx crawlee create "$PROJECT_NAME"
# after
[ -n "$PROJECT_NAME" ] || { echo 'PROJECT_NAME is empty'; exit 1; }
npx crawlee create "$PROJECT_NAME" Defensive patterns
Strategy: validation
Validate before calling
const name = process.argv[3] ?? '';
if (name.trim().length === 0) { console.error('Project name must be non-empty'); process.exit(1); } Type guard
function isValidProjectName(v: unknown): v is string { return typeof v === 'string' && v.trim().length > 0; } Try / catch
try { await createProject({ projectName: name }); } catch (err) { if (err.message.includes('cannot be empty string')) { console.error('Supply a non-empty project name'); } else { throw err; } } Prevention
- Quote and default shell variables: "${PROJECT_NAME:?PROJECT_NAME is required}"
- Validate CLI arguments in wrapper scripts before invoking the CLI
- Check CI variables are set before running crawlee create
When it happens
Trigger: Running the create command with a name that resolves to an empty string, e.g. `npx crawlee create ""` or passing a flag/argument that ends up empty after quoting/variable expansion.
Common situations: Shell scripts using unquoted/empty environment variables (`PROJECT_NAME=""`), CI pipelines interpolating an unset variable, accidental extra whitespace handling in wrappers.
Related errors
- Failed to infer format from the path: '${path}'. Supported f
- Unsupported format: '${format}'. Use one of ${supportedForma
- Invalid "proxyUrl". Unsupported protocol: ${proxyUrl}.
- Invalid "proxyUrl" option: authentication is only supported
- ${colors.red(`[${label}]`)}: All ${retries} attempts failed,
AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30).
Data as JSON: /api/errors/c41f09d0645e48a7.
Report an issue: GitHub.