{"record":{"id":"700b8976023522de","repo":"yarnpkg/yarn","slug":"name-should-not-start-with-got-str","errorCode":null,"errorMessage":"Name should not start with \"/\", got \"${str}\"","messagePattern":"Name should not start with \"/\", got \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/commands/create.js","lineNumber":23,"sourceCode":"import type {Reporter} from '../../reporters/index.js';\nimport * as child from '../../util/child.js';\nimport {makeEnv} from '../../util/execute-lifecycle-script';\nimport * as fs from '../../util/fs.js';\nimport {run as runGlobal, getBinFolder} from './global.js';\n\nconst path = require('path');\n\nexport function setFlags(commander: Object) {\n  commander.description('Creates new projects from any create-* starter kits.');\n}\n\nexport function hasWrapper(commander: Object, args: Array<string>): boolean {\n  return true;\n}\n\nexport function parsePackageName(str: string): Object {\n  if (str.charAt(0) === '/') {\n    throw new Error(`Name should not start with \"/\", got \"${str}\"`);\n  }\n  if (str.charAt(0) === '.') {\n    throw new Error(`Name should not start with \".\", got \"${str}\"`);\n  }\n  const parts = str.split('/');\n  const isScoped = str.charAt(0) === '@';\n  if (isScoped && parts[0] === '@') {\n    throw new Error(`Scope should not be empty, got \"${str}\"`);\n  }\n  const scope = isScoped ? parts[0] : '';\n  const name = parts[isScoped ? 1 : 0] || '';\n  const path = parts.slice(isScoped ? 2 : 1).join('/');\n  const fullName = [scope, name].filter(Boolean).join('/');\n  const full = [scope, name, path].filter(Boolean).join('/');\n\n  return {fullName, name, scope, path, full};\n}\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/create.js#L5-L41","documentation":"`yarn create <kit>` calls `parsePackageName` to split the argument into scope/name/path. At `create.js:23` it rejects a leading `/` because a package name starting with a slash is not a valid npm identifier and would resolve ambiguously. This is a pre-resolution input validation, before any network/linker work.","triggerScenarios":"`str.charAt(0) === '/'` — the first character of the builder argument is a forward slash, e.g. `yarn create /react-app`.","commonSituations":"Autocompleted or pasted path-like argument (`/react-app`), shell glob/tilde expansion leaking a slash, or confusion between a file path and a package name.","solutions":["Remove the leading slash: `yarn create react-app`.","If you meant a local directory starter, use an explicit path form supported by the create-* kit rather than a bare leading slash."],"exampleFix":"// before\n$ yarn create /react-app my-app\n\n// after\n$ yarn create react-app my-app","handlingStrategy":"validation","validationCode":"function assertValidCreateName(str: string): void {\n  if (str.charAt(0) === '/') {\n    throw new Error(`Package name must not start with '/': got '${str}'`);\n  }\n}\n// assertValidCreateName(builderName);","typeGuard":"function hasNoLeadingSlash(s: string): boolean {\n  return s.length > 0 && s.charAt(0) !== '/';\n}","tryCatchPattern":null,"preventionTips":["Sanitize kit-name inputs from UI/CLI before forwarding to `yarn create`.","Reject path-like inputs at the form/validation layer."],"tags":["yarn-create","validation","package-name"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}