Small Fixes for Your Package's Licence Information
Licence scanners, registry pages and corporate approval processes all read your package's licence metadata before a human ever looks at your code. Errors there cause real friction: blocked adoption, confused users, compliance tickets. These tips focus on the metadata and files, not on choosing a licence; each one is a quick fix with a reason.
In the manifest
- Use an exact SPDX identifier. Write
Apache-2.0, not "Apache 2.0" or "Apache License". Why: scanners match identifiers from the SPDX License List literally. - Write dual licensing as an expression.
MIT OR Apache-2.0. Why: "MIT/Apache" is ambiguous; OR and AND mean different things. - For Python, follow the current pyproject.toml specification. Newer versions of the specification, following PEP 639, accept an SPDX expression string in
licenseand alicense-fileslist. Why: the older table form and free-text classifiers are being phased out; check that your build backend supports the new fields. - Avoid "UNLICENSED" unless you mean it. In npm it signals that you grant no licence for others to use the package. Why: people sometimes confuse it with the Unlicense, which is a public-domain-style licence with its own identifier.
// package.json
{ "license": "MIT" }
# Cargo.toml
license = "MIT OR Apache-2.0"
# pyproject.toml
license = "BSD-3-Clause"
license-files = ["LICENSE"]
In the files
- Include the full licence text in the published artefact. Why: many licences, including MIT and BSD, require the notice to accompany copies; a manifest field alone is not the notice.
- Keep the copyright line meaningful. A name or "the Example Lib contributors" plus a year is common. Why: placeholder text such as "[fullname]" left from a template looks careless to reviewers.
- Make the manifest and the LICENSE file agree. Why: a mismatch forces every compliance reviewer to open a ticket asking which one is right.
- Consider SPDX headers in source files. A line such as
SPDX-License-Identifier: MITat the top of each file. Why: it survives when files are copied out of the repository.
For bundled or vendored code
- Keep third-party licences with the code you vendored. Why: your licence does not replace theirs.
- Reflect mixed licensing in the expression. If the package genuinely contains code under two licences, an AND expression describes that. Why: declaring only your own licence understates the obligations.
- Check bundled build output. Bundlers can inline dependencies into your
distfiles. Why: inlined code still carries its original licence terms, and many bundlers can emit a notices file for you.
Check how it displays
After publishing, look at your package page on the registry. If the licence shows as unknown or non-standard, the identifier is probably wrong. Fixing it needs a new release, so catch it early with a pre-release check. More detail: SPDX identifiers how-to and third-party licence notices.