From 471b56f1b50cc4bc0cb51d102f1e43260d4c5c92 Mon Sep 17 00:00:00 2001 From: Satvik Mishra <89024979+SatvikMishra08@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:20:27 +0000 Subject: [PATCH] docs: clarify os/cpu/libc accept string or array Closes #10002 --- .../content/configuring-npm/package-json.md | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/lib/content/configuring-npm/package-json.md b/docs/lib/content/configuring-npm/package-json.md index 56724afe699ab..8be6f755b9491 100644 --- a/docs/lib/content/configuring-npm/package-json.md +++ b/docs/lib/content/configuring-npm/package-json.md @@ -1122,7 +1122,8 @@ Unless the user has set the [`engine-strict` config](/using-npm/config#engine-st ### os -You can specify which operating systems your module will run on: +You can specify which operating systems your module will run on. +The value may be a string or an array of strings: ```json { @@ -1133,6 +1134,12 @@ You can specify which operating systems your module will run on: } ``` +```json +{ + "os": "linux" +} +``` + You can also block instead of allowing operating systems, just prepend the blocked os with a '!': ```json @@ -1150,6 +1157,7 @@ It is allowed to both block and allow an item, although there isn't any good rea ### cpu If your code only runs on certain cpu architectures, you can specify which ones. +Like `os`, the value may be a string or an array of strings: ```json { @@ -1160,6 +1168,12 @@ If your code only runs on certain cpu architectures, you can specify which ones. } ``` +```json +{ + "cpu": "x64" +} +``` + Like the `os` option, you can also block architectures: ```json @@ -1175,8 +1189,20 @@ The host architecture is determined by `process.arch` ### libc -If your code only runs or builds in certain versions of libc, you can specify which ones. -This field only applies if `os` is `linux`. +If your code only runs or builds against certain libc implementations, you can specify which ones. +Like `os` and `cpu`, the value may be a string or an array of strings. +This field only applies on Linux hosts. + +```json +{ + "os": [ + "linux" + ], + "libc": [ + "glibc" + ] +} +``` ```json {