Declaring Runtime Support With the engines Field
Every package supports some range of runtime versions, whether or not the author writes it down. Writing it down is cheap, and it turns a confusing syntax error on an old runtime into a clear message at install time. This post is about the engines field in package.json, its Python counterpart, and the policy questions behind them.
What the field says and what it does
In package.json, engines lists the runtime versions your package works with, using semver ranges:
{
"name": "example-parser",
"version": "3.1.0",
"engines": {
"node": ">=18"
}
}
The important nuance, according to the npm Docs, is that npm treats this as advisory by default: it prints a warning when the running version does not match, but it still installs the package unless the user has turned on the engine-strict setting. Some other package managers behave differently, so the field is best seen as documentation that tools can read, not a hard lock.
Python's equivalent is stricter. The requires-python key in pyproject.toml (standardised in PEP 621 metadata) is honoured by pip, which will skip releases whose requirement excludes the running interpreter and pick an older compatible one if available:
[project]
name = "example-parser"
version = "3.1.0"
requires-python = ">=3.9"
Choosing the range
I base the lower bound on the oldest runtime that is still supported upstream, not on the oldest one my code happens to run on. Runtimes publish their own support schedules, and supporting versions their own maintainers have abandoned tends to tie you to old tooling. For the upper bound, I almost never set one. An upper bound like <22 stops users from installing your package on a new runtime even when it works perfectly, and fixing that requires a new release.
Is raising the minimum a breaking change?
This is the question that causes the most arguments. My view: yes, treat dropping a runtime version as a major release, unless your project has published a policy saying otherwise. Users on the old runtime will get a failed install or an older version, and that is exactly the kind of surprise semantic versioning is supposed to signal.
Some projects instead publish a support policy, such as "we support runtime versions that are still maintained upstream and may drop older ones in a minor release". That is a legitimate choice as long as it is written in the README and repeated in the changelog when it happens.
A short checklist
- The declared range matches what CI actually tests. If CI only runs on two versions, do not claim four.
- The lower bound is reflected in your build target, so you do not emit syntax the minimum runtime cannot parse.
- The changelog says when the range changes, and why.
- There is no upper bound unless you know of a specific incompatibility.
It is a small field, but it is one of the few places where your support promise becomes something a machine can read. The glossary covers semver range syntax if you need a refresher.