Skip to content

Skip writing lockfile hash in postinstall when installed as a dependency (#725) - #726

Merged
mbohal merged 1 commit into
masterfrom
bug/725
Aug 14, 2026
Merged

Skip writing lockfile hash in postinstall when installed as a dependency (#725)#726
mbohal merged 1 commit into
masterfrom
bug/725

Conversation

@bedrich-schindler

Copy link
Copy Markdown
Contributor

No description provided.

@bedrich-schindler

Copy link
Copy Markdown
Contributor Author

Why this fix: alternatives considered

1. INIT_CWD/path heuristic (à la skip-local-postinstall)
Compares where npm install was invoked with where the script runs. Works for
the common case, but it is package-manager-specific, unset when the script is
run directly, and has symlink/workspace edge cases (it would skip the hash in
a legitimate checkout inside a monorepo). The referenced package actually
solves the inverse problem (skip locally, run for consumers) and would add a
dependency.

2. Append || true to the postinstall (the 0.63.0 style)
Hides the failure for consumers, but also silently swallows real errors in the
repo checkout.

3. Exit early when package-lock.json is absent ✅ (chosen)
npm unconditionally excludes the lockfile from published tarballs, so its
absence is a deterministic marker of "installed as a dependency" — not a
heuristic. It is package-manager- and invocation-independent, and its
worst-case failure mode is benign: the hash is not written and the
devcontainer just does one unnecessary reinstall.

@mbohal
mbohal merged commit 8e0d03f into master Aug 14, 2026
14 checks passed
@mbohal
mbohal deleted the bug/725 branch August 14, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

postinstall script in published 0.64.0 package breaks npm ci in consumer projects

3 participants