remix-run/remix · error · UsageError

Could not derive a valid package name from "${input}".

Error message

Could not derive a valid package name from "${input}".

What it means

The CLI normalizes a raw app name into a package name (lowercase, non-alphanumerics collapsed to hyphens, trimmed). If the result is the empty string, the input contained no usable characters and no valid package name can be derived.

Source

Thrown at packages/cli/src/lib/bootstrap-project.ts:247

  return parts
    .map((part) => {
      let head = part.slice(0, 1).toUpperCase()
      let tail = part.slice(1)
      return `${head}${tail}`
    })
    .join(' ')
}

function toPackageName(value: string): string {
  let packageName = value
    .trim()
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/^-+|-+$/g, '')

  if (packageName.length === 0) {
    throw invalidPackageName(value)
  }

  return packageName
}

View on GitHub (pinned to 9696913134)

Solutions

  1. Choose a name containing at least one letter or digit
  2. Rename the target directory to something alphanumeric
  3. Validate user-supplied names before passing to the CLI in tooling

Example fix

# before
$ remix new '---'

# after
$ remix new my-app
Defensive patterns

Strategy: type-guard

Validate before calling

function derivesPackageName(input: string): boolean {
  return input.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').length > 0
}

Type guard

function isValidAppName(input: string): input is string {
  return /^[a-zA-Z0-9]/.test(input.trim()) && /[a-zA-Z0-9]/.test(input)
}

Try / catch

try {
  await bootstrapProject(options)
} catch (error) {
  if (/valid package name/.test(error.message)) promptForName()
  else throw error
}

Prevention

When it happens

Trigger: toPackageName receives an input consisting solely of non-alphanumeric characters (e.g. '---', '!!!', '_____'), so after sanitization packageName.length === 0.

Common situations: Directory names made only of symbols/dashes; shell quoting mistakes producing an empty or symbolic string; programmatic appName values from unvalidated user input.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/03cc445747d5f519. Report an issue: GitHub.