usePackageJsonEngines (JSON)
Language JSON (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.6 - Diagnostic Category:
lint/nursery/usePackageJsonEngines - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Same as
package-json/require-engines
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "usePackageJsonEngines": "error" } } }}Description
Section titled “Description”Require the engines field in package.json.
The engines field lists the versions of Node.js and other tools that a package works
with. Package managers such as npm read this field and warn when someone installs the
package with a version outside that range. Without the field, nobody gets that warning,
and the package can fail in ways that are hard to connect to an unsupported version.
The rule only checks that the field exists at the top level of the file. It does not check
what the field contains. It applies to every package.json file, including packages that
set "private": true.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”{ "name": "my-package", "version": "1.0.0"}/package.json:1:1 lint/nursery/usePackageJsonEngines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This package.json file is missing the engines field.
> 1 │ {
│ ^
2 │ "name": "my-package",
3 │ "version": "1.0.0"
ℹ The engines field tells package managers which versions of Node.js and other tools the package works with. Without it, the package can be installed with an unsupported version and no warning is shown.
ℹ Add an engines field that lists the supported versions, for example "engines": { "node": ">=20" }.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
{ "name": "my-package", "version": "1.0.0", "engines": { "node": ">=20" }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.