Repository navigation
Description
[agent] Found by the scheduled npm bug-hunt routine (ledger #302).
Summary
An npm project whose .npmrc sets package-lock=false has no package-lock.json, because npm never writes one there. On such a project:
scan --mode vendoredfails (exit 1,vendor_lockfile_missing) and tells the user to "run your package manager's install first". Following that advice changes nothing.npm install(npm 8.19.4 and 12.2.3) still writes no lock underpackage-lock=false, so every re-run fails the same way.- A bare (hosted)
scanexits 0 withredirect_npm_no_lockfile("No package-lock.json / npm-shrinkwrap.json present") and gives no hint why, or what to do.
Neither message mentions the .npmrc setting that causes the problem. The CLI already reads that setting elsewhere: vex names npm package-lock=false in "Locks the package manager is told not to read" (CLI_CONTRACT.md). The pnpm counterpart has its own code naming the setting and a remedy that works (redirect_pnpm_lockfile_disabled: "removing the setting and running pnpm install", CLI_CONTRACT.md "pnpm with its lockfile off (#1074)").
Impact: friction, not harm. Nothing is written and no false claim is made. But a user who has never seen the tool follows the printed remedy and gets stuck in a loop, with nothing pointing at .npmrc.
Repro
SOCKET_API_URL etc. point at a local mock of the patch API that serves a free patch for left-pad@1.3.0. Any patched npm package shows the same thing.
mkdir p && cd p
echo 'package-lock=false' > .npmrc
echo '{"name":"p","version":"1.0.0","dependencies":{"left-pad":"^1.3.0"}}' > package.json
npm install # writes node_modules/ only, no package-lock.json
socket-patch scan --mode vendored --yes ; echo "exit=$?"
# Error: Cannot vendor pkg:npm/left-pad@1.3.0: no package-lock.json, npm-shrinkwrap.json, yarn.lock,
# pnpm-lock.yaml, bun.lock, bun.lockb, or vlt-lock.json in the project root — vendoring rewires the
# lockfile, so one must exist (run your package manager's install first)
# Vendored 0 packages; 1 failed.
# exit=1
npm install # the remedy as printed
ls # node_modules package.json (still no lock)
socket-patch scan --mode vendored --yes # same error, forever
socket-patch scan --yes ; echo "exit=$?"
# No patches could be switched to hosted:
# pkg:npm/left-pad@1.3.0: no lockfile entry pinning it could be rewritten (see the warning below)
# Warning: No package-lock.json / npm-shrinkwrap.json present
# exit=0What actually works: remove package-lock=false, or run npm install --package-lock. Either one writes a lock. Note that with the setting still in place, a plain npm install ignores the pins later; only npm ci honours them (already documented for vex).
Expected vs actual
- Expected: when the project's own
.npmrcsetspackage-lock(or its aliasshrinkwrap) tofalse, both modes say so, the way the pnpm path does withredirect_pnpm_lockfile_disabled. The remedy should be one that works: remove the setting and runnpm install. - Actual: vendored mode prints a remedy that can't succeed, and hosted mode prints a bare "no lockfile" warning with no remedy at all.
Versions
| socket-patch | npm | Reproduces |
|---|---|---|
main cfc870f |
12.2.3 | yes (vendored exit 1 with the looping remedy; hosted exit 0, no hint) |
main cfc870f |
8.19.4 (npm install as the remedy) |
yes, no lock written |
| v5.1.0 | 12.2.3 | yes, same messages |
This isn't a regression: v5.1.0 behaves the same. It's Linux-only testing, but the messages don't depend on the platform.
Suspect code
crates/socket-patch-core/src/vendor/npm_flavor.rs:264(and the twin at:1313):vendor_lockfile_missingalways appends "run your package manager's install first".crates/socket-patch-core/src/patch/redirect/mod.rs:1459:redirect_npm_no_lockfilehas no detail about why the lock is missing.- The
.npmrcpackage-lock/shrinkwrapreader thevexpath uses (crates/socket-patch-cli/src/commands/vex_sources.rs:308) could be reused here.
Generated by Claude Code
Activity
npm bughunt run 70: file:/git dep cells, #2379