Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-haiku-20241022· AnthropicHugging Face LMArena Human Preference 140K

what are the rules for "name" in package.json

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-lite-preview-06-17-thinking’s answer.
  1. User

    what are the rules for "name" in package.json

  2. Claude Assistant

    Here are the key rules and best practices for the "name" field in package.json:

    Naming Rules

    1. Required Field

      • The "name" is a mandatory field in package.json
    2. Length Constraints

      • Must be shorter than 214 characters
      • Recommended to keep it concise
    3. Naming Syntax

      • Must be all lowercase
      • Single word or hyphen-separated
      • No spaces allowed
      • Can include numbers
      • Can use dots and underscores

    Valid Examples

    {
      "name": "my-project",
      "name": "myproject",
      "name": "my-project-123",
      "name": "my.project",
      "name": "my_project"
    }
    

    Invalid Examples

    {
      "name": "My Project",  // Contains spaces
      "name": "My-Project",  // Contains uppercase
      "name": "@org/My-Project"  // Uppercase (without scope)
    }
    

    Scoped Packages

    • Can start with @ for organization-scoped packages
    • Format: @organization/package-name
    {
      "name": "@myorg/my-project"
    }
    

    Recommendations

    • Use lowercase
    • Use hyphens for readability
    • Be descriptive but concise
    • Avoid special characters except -, ., _

    NPM Registry Specific Rules

    • Must be unique on npm
    • Cannot contain uppercase letters
    • Cannot start with a dot or an underscore
    • Cannot have leading/trailing spaces
    • Cannot have URL-unsafe characters

    Best Practices

    • Use kebab-case (lowercase with hyphens)
    • Reflect the project's purpose
    • Check npm registry for name availability
    • Avoid generic names that might conflict

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.