usePackageJsonValidEngines (JSON)
Language JSON (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.3 - Diagnostic Category:
lint/nursery/usePackageJsonValidEngines - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Same as
package-json/valid-engines
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "usePackageJsonValidEngines": "error" } } }}Description
Section titled “Description”Enforce that the engines field in package.json is valid.
The engines field lists the programs that a package works with, such as Node.js or npm,
and the versions of each program that the package supports. Package managers read this
field to warn people who install the package with an unsupported version.
The field must be an object. Each property name is the name of a program, and each property
value is a version range: a string such as >=20 that describes the supported versions.
This rule reports the engines field when:
- it is not an object;
- one of its property values is not a string;
- one of its property values is an empty string, or a string that contains only whitespace.
The rule doesn’t check whether a string is a valid version range.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”{ "engines": { "node": 24 }}/package.json:3:17 lint/nursery/usePackageJsonValidEngines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The version range for "node" in engines is not a string.
1 │ {
2 │ "engines": {
> 3 │ "node": 24
│ ^^
4 │ }
5 │ }
ℹ Package managers compare the installed version of "node" with this value. They can only read a version range that is written as a string.
ℹ Write the supported versions as a string, such as ">=24".
ℹ 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.
{ "engines": { "node": "" }}/package.json:3:17 lint/nursery/usePackageJsonValidEngines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The version range for "node" in engines is empty.
1 │ {
2 │ "engines": {
> 3 │ "node": ""
│ ^^
4 │ }
5 │ }
ℹ An empty version range doesn't tell package managers which versions of "node" the package supports.
ℹ Write the supported versions, such as ">=24", or remove this property.
ℹ 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.
{ "engines": ["node >=24"]}/package.json:2:16 lint/nursery/usePackageJsonValidEngines ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The engines field is not an object.
1 │ {
> 2 │ "engines": ["node >=24"]
│ ^^^^^^^^^^^^^
3 │ }
4 │
ℹ Package managers read engines to find the versions of each program that the package supports. They expect an object that maps each program name to a version range.
ℹ Use an object, such as { "node": ">=24" }.
ℹ 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.
{ "engines": { "node": "^24.11.0", "npm": ">=11" }}See Also
Section titled “See Also”- To report empty property names, including those in
engines, seenoEmptyObjectKeys.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.