yarnpkg/yarn · error · Error

Name should not start with ".", got "${str}"

Error message

Name should not start with ".", got "${str}"

What it means

Same `parsePackageName` validator; at `create.js:26` it rejects a leading `.` because relative-path package names are not valid npm package identifiers. The check fires before scope/name splitting.

Source

Thrown at src/cli/commands/create.js:26

import * as fs from '../../util/fs.js';
import {run as runGlobal, getBinFolder} from './global.js';

const path = require('path');

export function setFlags(commander: Object) {
  commander.description('Creates new projects from any create-* starter kits.');
}

export function hasWrapper(commander: Object, args: Array<string>): boolean {
  return true;
}

export function parsePackageName(str: string): Object {
  if (str.charAt(0) === '/') {
    throw new Error(`Name should not start with "/", got "${str}"`);
  }
  if (str.charAt(0) === '.') {
    throw new Error(`Name should not start with ".", got "${str}"`);
  }
  const parts = str.split('/');
  const isScoped = str.charAt(0) === '@';
  if (isScoped && parts[0] === '@') {
    throw new Error(`Scope should not be empty, got "${str}"`);
  }
  const scope = isScoped ? parts[0] : '';
  const name = parts[isScoped ? 1 : 0] || '';
  const path = parts.slice(isScoped ? 2 : 1).join('/');
  const fullName = [scope, name].filter(Boolean).join('/');
  const full = [scope, name, path].filter(Boolean).join('/');

  return {fullName, name, scope, path, full};
}

export function coerceCreatePackageName(str: string): Object {
  const pkgNameObj = parsePackageName(str);
  const coercedName = pkgNameObj.name !== '' ? `create-${pkgNameObj.name}` : `create`;

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Drop the leading dot: `yarn create react-app`.
  2. For a local starter, invoke the kit's binary directly instead of via `yarn create`.

Example fix

// before
$ yarn create ./starter my-app

// after
$ yarn create starter my-app
Defensive patterns

Strategy: validation

Validate before calling

function assertNoLeadingDot(str: string): void {
  if (str.charAt(0) === '.') {
    throw new Error(`Package name must not start with '.': got '${str}'`);
  }
}

Type guard

function hasNoLeadingDot(s: string): boolean {
  return s.length > 0 && s.charAt(0) !== '.';
}

Prevention

When it happens

Trigger: `str.charAt(0) === '.'` — argument like `yarn create ./react-app` or `yarn create .foo`.

Common situations: Passing a relative path instead of a kit name, or a stray dot from a typo / shell history substitution.

Related errors


AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13). Data as JSON: /api/errors/b9af3140326a34b5. Report an issue: GitHub.