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

  1. Pass a non-empty project name to the create command.
  2. In scripts, validate `${PROJECT_NAME}` is non-empty before invoking the CLI.
  3. 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

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


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/c41f09d0645e48a7. Report an issue: GitHub.