Skip to content

fix(release): package-lock.json version drifts because semantic-release never commits it #662

Description

@jooyoungseo

Bug Report

Description

package-lock.json records a version six releases behind package.json:

package.json version : 3.74.0
lock .version        : 3.68.0
lock packages[""]    : 3.68.0

@semantic-release/npm bumps the version in both files during a release, but .releaserc.json only commits the first one back:

[
  "@semantic-release/git",
  {
    "assets": ["package.json", "CHANGELOG.md"],
    "message": "chore(release): ${nextRelease.version} [skip ci]"
  }
]

package-lock.json is missing from assets, so the bump is made in the runner's working tree and then discarded. The drift is exactly the release count since the lockfile was last committed by hand — 3.68.0, 3.69.0, 3.70.0, 3.71.0, 3.72.0, 3.72.1, 3.73.0, 3.74.0.

Steps to Reproduce

  1. git checkout main
  2. node -p "require('./package.json').version" → 3.74.0
  3. node -p "require('./package-lock.json').version" → 3.68.0
  4. Run any npm install or npm i -D <package> and inspect git diff package-lock.json.

Actual Behavior

Step 4 rewrites the two version fields as a side effect, so an unrelated diff rides along with any dependency change:

-  "version": "3.68.0",
+  "version": "3.74.0",

npm ci is unaffected — it does not compare that field — so CI stays green and nothing surfaces the drift.

Expected Behavior

The committed lockfile records the same version as package.json, and adding a dependency produces a diff containing only that dependency.

Additional Information

Suggested fix. Add package-lock.json to the @semantic-release/git assets:

"assets": ["package.json", "package-lock.json", "CHANGELOG.md"]

That needs a one-time npm install commit to resync the field to the current version; afterwards each release keeps the two in step. Worth pairing with the existing note in .claude/rules/git-workflow.md that semantic-release owns the version field, so the lockfile is understood to be owned by it too.

How this surfaced. In #659 I needed to promote jsdom from a transitive dependency to an explicit devDependency. npm i -D jsdom@^22.1.0 produced 65 lines of unrelated lockfile churn — this version bump plus removal of libc metadata from ~20 optional dependencies. The libc removal is a separate, environment-dependent effect (npm 10.9.7 / Node 22.22.2 here, evidently not what last wrote the file) and is not caused by the release config; flagging it only because it compounds the same symptom.

I ended up hand-editing package.json and the lockfile's root devDependencies entry, validating with npm ci --dry-run, to keep that churn out of an accessibility fix. That workaround does not scale — a package with its own dependency tree cannot be added by hand — which is what makes this worth fixing rather than routing around.

Consequence worth tracking. Reviewers on #659 suggested replacing that test's hand-built jsdom globals with a real jest-environment-jsdom dependency. That change is currently blocked on this one: it needs a new devDependency with its own transitive tree, so it cannot avoid the churn until the lockfile is in a clean state. Happy to file that separately once this is resolved.

Activity

  1. added theissue type on Jul 29, 2026
  2. added a commit that references this issue on Oct 17, 2026
    1b64cd7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址