socket npm install/uninstall removes optional peer entries from package-lock.json
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 47/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- backend, build-system, cli
調査の方向性
Start by tracing the incremental socket npm install and socket npm uninstall paths that update package-lock.json, then compare their handling of entries marked both "optional": true and "peer": true with the from-scratch lockfile path. The issue does not name source files or tests, so locate those entry points and their lockfile tests in the repository. Done means unrelated incremental operations retain these entries and npm ci rejects a lockfile missing required peer entries, consistently with npm.
索引モデルが issue の本文から書いたものです。
説明
Summary
Incremental socket npm install <pkg> and socket npm uninstall <pkg> remove every
package-lock.json entry flagged "optional": true, "peer": true (a package present only
to satisfy a peer dependency of an optional dependency). The removal occurs regardless of
which package is installed or uninstalled.
- Real npm, same operation: entries retained.
- From-scratch generation (
socket npm install --package-lock-onlywith no lockfile): not
affected. npm cion the result:EUSAGE,Missing: <pkg> from lock file.socket npm cion the result: exits 0 and installs the tree without the peer.
Expected vs. actual
| Expected (matches npm) | Actual (socket npm) |
|
|---|---|---|
Lockfile after install / uninstall of an unrelated package |
"optional": true, "peer": true entries retained |
Entries removed |
socket npm ci on a lockfile missing those entries |
Fails with EUSAGE, as npm ci does |
Exits 0 and installs the tree without the peer |
Environment
| Component | Version |
|---|---|
| Socket CLI | 1.12.1 (latest, 2026-10-29); also reproduced on 1.1.94 |
npm (wrapped by socket npm, and standalone) |
11.16.0; also reproduced on 11.19.1 (CLI 1.1.94) |
| Socket Firewall | sfw Free 1.15.4, 1.15.6 |
| Node | 24.22.1 |
| OS / arch | Linux arm64 (OrbStack) |
| Registry | https://registry.npmjs.org/ |
| Socket auth | none (token: (not set)) |
Minimal reproduction
package.json:
{
"name": "repro",
"version": "1.0.0",
"private": true,
"dependencies": { "@fontsource/ibm-plex-mono": "^5.3.0" },
"optionalDependencies": { "react-dom": "18.3.1" }
}
[email protected] declares peerDependencies: { "react": "^18.3.1" }. npm records react
with "optional": true, "peer": true.
# 1. Baseline lockfile (real npm)
npm install --package-lock-only
grep -c '"peer": true' package-lock.json # 1 (react)
# 2. Uninstall an unrelated package via the Socket CLI
socket npm uninstall @fontsource/ibm-plex-mono --package-lock-only
grep -c '"peer": true' package-lock.json # 0
# 3. npm ci (real npm)
npm ci --dry-run
# npm error code EUSAGE
# npm error Missing: [email protected] from lock file
# 4. sfw npm ci
sfw npm ci --dry-run # EUSAGE, Missing: [email protected]
# 5. socket npm ci
socket npm ci --ignore-scripts # exit 0, "added 4 packages"
ls node_modules # js-tokens loose-envify react-dom scheduler
Controls:
- Step 2 with real npm (
npm uninstall @fontsource/ibm-plex-mono --package-lock-only):
reactretained;npm cipasses. - Step 2 as
socket npm install @fontsource/inter --package-lock-only:reactremoved;
same result asuninstall.
Test matrix
Method:
- Baseline lockfile generated with real npm; the Socket CLI performs only the incremental
operation. - Operations:
uninstall @fontsource/ibm-plex-mono,install @fontsource/inter. Neither
touches the peer packages. - Validation of the Socket-produced lockfile:
npm ci --dry-run,sfw npm ci --dry-run,
socket npm ci --ignore-scripts. - 2 runs per case and operation; all runs identical.
Socket CLI 1.12.1, npm 11.16.0, sfw 1.15.6:
| Case | Peer entry flags (baseline) | socket npm install / uninstall |
npm install / uninstall | npm ci |
sfw npm ci |
socket npm ci |
|---|---|---|---|---|---|---|
react-dom direct |
peer |
retained | retained | pass | pass | pass |
react-dom + react direct |
none | retained | retained | pass | pass | pass |
react-dom optional |
peer, optional |
removed | retained | fail | fail | pass |
@napi-rs/wasm-runtime direct |
peer |
retained | retained | pass | pass | pass |
@napi-rs/wasm-runtime + @emnapi/* direct |
none | retained | retained | pass | pass | pass |
@napi-rs/wasm-runtime optional |
peer, optional |
removed | retained | fail | fail | pass |
fail=EUSAGE,Missing: <peer> from lock file.- CLI
1.1.94: install/uninstall columns identical on npm11.16.0and11.19.1;
socket npm ciexit 0 on the brokenreact-domlockfile.
Excluded factors:
| Factor | Evidence |
|---|---|
| Peer dependency alone | peer-only entries retained (rows 1, 4) |
| Specific package | Reproduces with react and @emnapi/* |
| Prerelease versions | Removed @emnapi/core is stable 1.11.3 |
| npm version skew | Wrapped and standalone npm identical in each run |
| Outdated CLI | Reproduces on latest release 1.12.1 |
Original occurrence
- Project: Astro site, July 2026.
- Path:
astro→ build tooling →@napi-rs/[email protected](optional) → peer
@emnapi/core ^2.0.0-alpha.3,@emnapi/runtime ^2.0.0-alpha.3. - No other dependent on
@emnapi/*2.x, so@emnapi/core,@emnapi/runtimeand
@emnapi/wasi-threadswerepeer+optionalentries. - Trigger:
socket npm install(3 packages), thensocket npm uninstall(2 packages).
All three entries removed; CInpm cifailed. - Current resolution of the same
package.jsondoes not reproduce: a newer astro
dependency requires@emnapi/[email protected]directly, so the entries are no longer
peer-only. - Reproduces with dependencies resolved as of that date:
npm install --package-lock-only --before=2026-07-30.
Impact
| Command | Result on the affected lockfile |
|---|---|
npm ci |
fail — EUSAGE, Missing: <peer> from lock file |
sfw npm ci |
fail — same error |
socket npm ci |
pass — installs the tree without the peer |
- The CLI produces the inconsistent lockfile and also passes it on
ci. Withnpm
aliased tosocket npm, localnpm ci,npm ci --dry-runand builds all pass; the
failure surfaces only in environments running real npm (CI). sfwdelegates to real npm and is unaffected: it rejected every broken lockfile in the
matrix.
Related
Not re-verified since the original occurrence. From-scratch lockfiles from the Socket CLI
omitted libc fields that npm records on platform-specific packages:
"cpu": [ "arm64" ],
+ "libc": [
+ "glibc"
+ ],
"optional": true,
No effect on npm ci validation. Output is not byte-identical to npm's.
Not tested
- Mechanism (only the effect is observed).
- Authenticated CLI, org policies.
- Peers optional via
peerDependenciesMetarather than via an optional dependency.
Questions
- Does the incremental path rebuild the ideal tree, or edit the existing lockfile in
place? In-place handling that treats"optional": true, "peer": trueentries as
removable would match the observed behaviour. - Why does
socket npm ciaccept a lockfile thatnpm cirejects? This divergence hides
the defect until CI. - Is the omission of
libcfields intentional?
Workaround
Generate and validate lockfiles with real npm, bypassing the wrapper:
/usr/bin/npm install --package-lock-only
/usr/bin/npm ci # must pass before commit
sfw npm ci is safe locally and in CI; it does not alter npm's behaviour.
- 主要言語
- TypeScript
- スター
- 336
- フォーク
- 72
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 87
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SocketDev/socket-cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
SocketDev/socket-cli#1655 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SocketDev/socket-cli#1160 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
SocketDev/socket-cli#1675 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
SocketDev/socket-cli#1674 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`socket npm outdated --json` appends an error object after valid JSON when npm exits with code 1オープン
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
SocketDev/socket-cli#1656 ·
メンテナーはふだん 1 日以内に返信
SocketDev/socket-cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Northeastern-Electric-Racing/FinishLine#4660 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
excaliburjs/Excalibur#3895 ·
メンテナーはふだん 3 日以内に返信
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejected対応中かも @Steve-20-ai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Earn report crashes with "RangeError: Invalid time value" when a report row has an unparsable timestamp対応中かも @Gurkaran18 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
joinmarket-webui/jam#1588 ·
メンテナーはふだん 3 日以内に返信
-
BeOS .json missingオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mihaip/infinite-mac#475 ·