Repository, License, and Metadata
You'll learn how to document your package's origins, legal terms, and authorship in package.json so users know where it lives, how they can use it, and who maintains it.
Why These Fields Matter
Think of these fields as your package's identity card and legal fine print. When someone installs your package, they might want to file a bug, check the license terms, or know who to thank. These metadata fields answer those questions before anyone has to ask.
Repository: Where the Code Lives
The repository field tells the world where your source code is hosted:
{
"repository": {
"type": "git",
"url": "https://github.com/username/project.git"
}
}
Shorthand also works:
{
"repository": "github:username/project"
}
This lets tools auto-generate links to your code and issue tracker.
License: Legal Clarity
The license field defines usage terms. Use standard SPDX identifiers like "MIT", "Apache-2.0", or "ISC":
{
"license": "MIT"
}
If you have multiple or unusual licenses, use an array or "SEE LICENSE IN <filename>".
Author and Contributors
Document who built the package:
{
"author": "Jane Doe <jane@example.com> (https://jane.dev)",
"contributors": [
"Bob Smith <bob@example.com>"
]
}
This helps users know who to credit or contact.
Other Metadata
Fields like keywords, homepage, and bugs improve discoverability and support:
{
"keywords": ["logging", "debug"],
"homepage": "https://myproject.dev",
"bugs": "https://github.com/username/project/issues"
}
Key Takeaway: Repository, license, and metadata fields transform your package.json from a technical manifest into a complete package identity—telling users where to find code, how they can use it, and who built it.