[DOCS] Clarify whether `os`, `cpu`, and `libc` accept a string or must be an array
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
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 (sametypeof 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"makesyarn installfail withinvalid type: string "glibc", expected a sequenceand 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) typesosandcpuasarrayofstringonly, so"os": "linux"is flagged as invalid in editors — and it has no top-levellibcproperty at all, solibcgets 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from npm/cli
-
[DOCS] `npm trust circle` docs should warn that OIDC token exchange in SSH reruns isn't supported OpenDocumentation Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
allowScripts Bug Needs Triage Priority 2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Bug Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·
-
client-controller-update ta-bot-triage team-money-movement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MetaMask/metamask-mobile#36594 ·