Repository navigation
Description
Where
.github/actions/npm/jobs/publish-npm/generate-command.mjs and .github/actions/npm/jobs/publish-github-packages/generate-command.mjs both build the default publish command as:
finalCommand = `${tool} --access ${accessLevel}`;(plus --provenance for public npm). Neither adds --ignore-scripts.
What happens
.github/actions/npm/steps/publish-package/action.yml downloads the package-contents build artifact (the npm pack-expanded output of an earlier build job) and runs the generated command with working-directory: package-contents. That directory has no node_modules and — critically — no package-lock.json (npm never publishes lockfiles, and it isn't in a package's "files" either, so there's nothing to npm ci/npm install against even if you wanted to).
npm publish (and pnpm publish/yarn publish) always fires lifecycle scripts (prepack, prepublishOnly, postpack, …) regardless of whether the target directory is a fresh source checkout or an already-built artifact. For any repo whose prepack (or similar) does real work requiring devDependencies — e.g. a bundler build — that script now runs a second time, in a directory that structurally cannot supply what it needs, and crashes the publish outright.
This is the same class of problem as #250 (prepare crashing on a file excluded from "files"), but it's not fixable per-repo the same way: prepare's fix could wrap the missing file in a try/catch no-op because it had nothing legitimate left to do. A repo with a real bundler build (e.g. tsup producing dist/) has no file to fall back to if dist/ itself is missing or stale — the per-repo workaround has to reach for a heuristic ("is the toolchain even available here") instead of a clean no-op, which is a strong signal the guard belongs upstream, not in every consuming repo's package.json.
Why --ignore-scripts is the correct fix here specifically
The reusable publish workflow already runs build_command explicitly in the build job, before packing. By the time execution reaches the publish job, the artifact is supposed to be treated as immutable, already-verified output — no lifecycle script has any legitimate work left to do, and none of them can succeed anyway (no node_modules, no lockfile). Passing --ignore-scripts on the generated publish command matches that invariant exactly, for every consuming repo, without requiring each one to defensively detect "am I in the bare artifact dir or not."
Repro
CLDMV/vitest-runner's v1.4.0 release: both 📦 Publish to NPM and 📦 Publish to GitHub Packages failed identically with sh: 1: tsup: not found (exit 127) once the repo added a real tsup build behind a "prepack": "npm run build" script. The repo currently works around it locally via a node_modules/.bin/tsup-existence check in its own prepack (see PR #40), but that's a per-repo patch for what looks like a workflow-level gap.
Ask
- Add
--ignore-scriptsto the default generated command in bothgenerate-command.mjsfiles. - If a repo passes a custom
publish_command/github_packages_publish_command, that's presumably intentional and out of scope for this default — but worth a doc note indocs/conventions/(wherever the publish flow is documented) calling out that a custom command should probably include it too, given the bare artifact has nonode_modules. - Once released,
CLDMV/vitest-runner#(follow-up TBD) will drop its local workaround.
Activity
Shinrai commentedon Sep 28, 2026
Fix is up in #321 (c4dc1aa). The default publish command now passes
--ignore-scriptsfor both npm and GitHub Packages, with any package manager.The issue names the two
generate-command.mjsfiles, but those are only fallbacks. The command the reusable workflow actually runs, for the core package and every satellite, comes fromgithub/utilities/repo-detection/action.mjs, a third copy of the same builder. All three now call one sharedbuildPublishCommand()innpm/utilities/publish-command/(with unit tests), so the flag can't drift between them.Checked against an npm-pack'd artifact whose
prepackcalls a missing binary. Without the flag,npm publish --dry-runexits 127 (not found, the same failure as vitest-runner v1.4.0) and pnpm fails the same way. With the flag, both publish cleanly. yarn v1 and pnpm both accept--ignore-scriptsonpublish.A custom
publish_command/github_packages_publish_commandis still used as-is. The caveat about adding--ignore-scriptsyourself is now indocs/conventions/package-manager.md→ "Publishing from the build artifact". Once this is released, vitest-runner can drop its localprepackguard.cldmv-bot commentedon Sep 28, 2026
Closed in v4.29.1 — resolved by #321.