[DOCS] Clarify whether `os`, `cpu`, and `libc` accept a string or must be an array

Open Beginner friendly
#10,002 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, node.js
Domain
cli, documentation

Research direction

Start at the package.json documentation page linked in the issue and compare the os, cpu, and libc sections and their examples. Clarify the supported value type consistently across those sections, with wording and examples that match the documented behavior; confirm the page no longer presents conflicting guidance.

Written by the indexing model from the issue text.

Description

Documentation Needs Triage
Is there an existing issue for this?
  • I have searched the existing issues
This is a CLI Docs Enhancement, not another kind of Docs Enhancement.
  • This is a CLI Docs Enhancement.
Description of Problem

The package.json docs are internally inconsistent about the type of the os, cpu, and libc fields, and the ecosystem has diverged as a result.

The os section documents an array:

{
  "os": ["darwin", "linux"]
}

The cpu section likewise documents an array. But the libc section, a few paragraphs below, documents both fields as plain strings:

{
  "os": "linux",
  "libc": "glibc"
}

Nowhere does the page state whether a bare string is a supported shorthand or whether the libc example is simply a mistake.


Because npm silently accepts both, packages in the wild use both, and consumers of the manifest have made incompatible choices:

  • npm — accepts string or array.
  • pnpm (@pnpm/package-is-installable) — accepts string or array (same typeof list === 'string' coercion).
  • Yarn Berry (packages/yarnpkg-core/sources/Manifest.ts) — requires an array. A string is silently discarded, so the platform constraint is lost without any warning.
  • Yarn 6 / zpm — requires an array and now hard-errors: yarnpkg/zpm#210, where sass-embedded's "libc": "glibc" makes yarn install fail with invalid type: string "glibc", expected a sequence and exit code 1. In that thread a user asks, reasonably, why a string isn't supported, citing this very npm docs page as justification for the package author's choice.
  • SchemaStore (https://json.schemastore.org/package.json, the schema VS Code uses by default) types os and cpu as array of string only, so "os": "linux" is flagged as invalid in editors — and it has no top-level libc property at all, so libc gets no validation or completion whatsoever.

So an author who copies the documented libc example directly gets an editor warning, a silently dropped constraint under Yarn Berry, and a failing install under Yarn 6.

Potential Solution

No response

Docs URL

https://docs.npmjs.com/cli/v12/configuring-npm/package-json#libc

Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
21

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from npm/cli

All issues in npm/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.