Skip to content

usePackageJsonCpu (JSON)

Language JSON (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"usePackageJsonCpu": "error"
}
}
}
}

Require the cpu field in package.json.

The cpu field lists the processor types that a package can run on, such as x64 or arm64. Package managers read it to avoid installing the package on a processor that the package doesn’t support. Without the field, the package is installed on every processor, and a package that can’t run there fails later, when it is used.

This rule reports a package.json file whose outermost object has no cpu field. A cpu field inside another object doesn’t count. The rule doesn’t check the value of the field.

package.json
{
"name": "my-package",
"version": "1.0.0"
}
/package.json:1:1 lint/nursery/usePackageJsonCpu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This package.json file is missing the cpu field.

> 1 │ {
│ ^
2 │ "name": "my-package",
3 │ "version": "1.0.0"

ℹ Package managers read this field to avoid installing the package on a processor that the package doesn't support.

ℹ Add a cpu field that lists the processor types the package supports, for example ["x64", "arm64"].

ℹ 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.

package.json
{
"name": "my-package",
"version": "1.0.0",
"cpu": ["x64", "arm64"]
}