Skip to content

fix(npm): read install.js version from package.json#37

Merged
thegdsks merged 1 commit intomasterfrom
chore/npm-version-from-package-json
May 7, 2026
Merged

fix(npm): read install.js version from package.json#37
thegdsks merged 1 commit intomasterfrom
chore/npm-version-from-package-json

Conversation

@thegdsks
Copy link
Copy Markdown
Member

@thegdsks thegdsks commented May 7, 2026

What this fixes

npm/install.js had a hard-coded VERSION = '0.3.0' constant. Meanwhile the release workflow runs npm version $tag against package.json at publish time. So package.json got the right version on release, but install.js kept downloading the 0.3.0 archive — silently shipping an old binary to anyone running npm install -g stacklit.

Reading the version from ./package.json at runtime makes the release-time npm version bump the single source of truth. One field, one place to update.

Why this matters now

We're about to tag the first release that bundles the export command (#36) and the Windows install fix (#35). Without this fix, that release would publish [email protected] on npm, but the postinstall would still try to download the v0.3.0 release archive — losing both new features for anyone installing via npm.

Test plan

  • node --check npm/install.js passes
  • cd npm && node -e "console.log(require('./package.json').version)" returns the current version
  • On the next release, verify npm install -g stacklit pulls the matching tagged archive

The release workflow runs 'npm version $tag' to bump package.json from
the git tag, but install.js had its own hard-coded VERSION = '0.3.0'
constant that nothing was updating. So at release time the package
metadata says (e.g.) 0.4.0 while the postinstall still downloads the
0.3.0 binary archive, silently shipping an older binary to anyone
running 'npm install -g stacklit'.

Reading the version from ./package.json makes that release-time bump
the single source of truth. No new dependency, no extra release step,
and the version stays correct for pre-releases ('0.4.0-beta.1' style)
since goreleaser uses the same scheme for its archive names.
Copilot AI review requested due to automatic review settings May 7, 2026 02:34
@thegdsks thegdsks added the bug Something isn't working label May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes npm postinstall downloading the wrong release archive by making npm/install.js derive the version from package.json, matching the version set by the release workflow.

Changes:

  • Replace hard-coded VERSION in npm/install.js with require('./package.json').version
  • Add inline documentation explaining the drift issue and why package.json is the single source of truth

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thegdsks thegdsks merged commit 9e60662 into master May 7, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants