what are the rules for "name" in package.json
- User
what are the rules for "name" in
package.json Assistant
Here are the key rules and best practices for the "name" field in
package.json:Naming Rules
-
Required Field
- The "name" is a mandatory field in
package.json
- The "name" is a mandatory field in
-
Length Constraints
- Must be shorter than 214 characters
- Recommended to keep it concise
-
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
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.