GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: show full parent command path in subcommand usage errors by shaanmajid · Pull Request #9404 · npm/cli

Conversation

@shaanmajid

@shaanmajid shaanmajid commented May 25, 2026

Copy link
Copy Markdown

Summary

  • Subcommand runtime usage errors (e.g., npm stage approve without a <stage-id>) rendered the bare subcommand name (e.g., npm approve <stage-id>) and Run "npm help approve" for more info -- pointing at a command and help page that don't exist.
  • The subcommand instance now carries its parent command name, so usage output and usageError render the full path (npm stage approve <stage-id>) and point to the real help page (npm help stage)

This fix applies to npm stage and npm trust.

Implementation

  • lib/npm.js: set parentName on the subcommand instance during dispatch (and use the full joined path on the --help branch for parity).
  • lib/base-cmd.js: the instance usage getter threads parentName into getUsage, and the help footer resolves to the top-level documented command.

References

Fixes #9403

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
shaanmajid added 2 commits May 22, 2026 20:56
@shaanmajid
fix: show full parent command path in subcommand usage errors
691684d
@shaanmajid
test: assert stage approve usage error shows full command path
4bd0748
@shaanmajid
shaanmajid requested review from a team as code owners May 25, 2026 20:48
@swarnim-dev

swarnim-dev commented May 28, 2026

Copy link
Copy Markdown

Tested this locally and can confirm it works. Ran the test suite and everything passes:

  • stage/approve tests: 5/5 ✅
  • trust command tests: 71 assertions across 5 files ✅

The fix does what it's supposed to - error messages now show the full command path like "npm stage approve " instead of the broken "npm approve ". Verified it works for both stage and trust subcommands.

Code looks solid, no edge cases I can find, and there's good test coverage.

Ready to ship acc. to me!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shaanmajid
test: regenerate install snapshots for shifted source line numbers
40655c0
@shaanmajid

shaanmajid commented May 28, 2026

Copy link
Copy Markdown
Author

CI failures were from stale snapshot; should be fixed with 40655c0

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@owlstronaut owlstronaut added the backport:v11 label Jun 2, 2026
owlstronaut
owlstronaut approved these changes Jun 2, 2026
View reviewed changes
@owlstronaut
owlstronaut merged commit fe41ae7 into npm:latest Jun 2, 2026
22 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ Backport to release/v11 failed.

This usually means the cherry-pick had conflicts. Please create a manual backport:

git fetch origin release/v11
git checkout -b backport/v11/9404 origin/release/v11
git cherry-pick -x fe41ae7c6b38e7e9957b646bf379e2b5daae03f9
# resolve any conflicts, then:
git push origin backport/v11/9404
Error details
Command failed: git cherry-pick -x fe41ae7c6b38e7e9957b646bf379e2b5daae03f9
error: could not apply fe41ae7c6... fix: show full parent command path in subcommand usage errors (#9404)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@owlstronaut owlstronaut mentioned this pull request Jun 2, 2026
Fix usage path for subcommand errors #9434
Closed
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
chore: release 12.0.0-pre.1 #9387
Merged
@shaanmajid
shaanmajid deleted the fix/subcommand-usage-path branch June 2, 2026 14:53
@owlstronaut owlstronaut mentioned this pull request Jun 2, 2026
fix: show full parent command path in subcommand usage errors #9464
Merged
owlstronaut pushed a commit that referenced this pull request Jun 2, 2026
Michael Smith
fix: show full parent command path in subcommand usage errors (#9464)
c069622
backport of #9404
@npm-cli-bot npm-cli-bot mentioned this pull request Jun 23, 2026
deps: upgrade npm to 12.0.0-pre.1 nodejs/node#64096
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@owlstronaut owlstronaut owlstronaut approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport:v11

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] Subcommand usage errors show the wrong command path (e.g. "npm approve" instead of "npm stage approve")

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@shaanmajid @swarnim-dev @owlstronaut
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.