-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: much clearer npx 'canceled' error #6642
Conversation
// set -n to always say no | ||
if (yes === false) { | ||
throw new Error('canceled') | ||
// Error message lists missing package(s) when process is canceled | ||
throw new Error(`npx canceled due to missing packages and no YES option: ${JSON.stringify(missingPackages)}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error(`npx canceled due to missing packages and no YES option: ${JSON.stringify(missingPackages)}`) | |
/* eslint-disable-next-line max-len */ | |
throw new Error(`npx canceled due to missing packages and no YES option: ${JSON.stringify(missingPackages)}`) |
Can you please add the max-len override for the thrown error, then run |
Thanks for the feedback, we made the appropriate changes that you suggested! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
What does "no YES option" mean? How can you correct this if you encounter this error? What is the option you need to add? |
The “no YES option” is what If you want your command to execute, instead of using |
Summary
Currently, when running npx --no-install on a package that is not installed will return a vague error message that says, “canceled.”
Added accompanying tap test to ensure the expected error is outputted.
This solution gives the error message more clarity to make debugging easier.
Testing
Reproduce Original Error:
npx --no-install <missing_package>
Please Note:
<missing_package>
is either not installed or in pathTap Test (exec.js only)
node . run test test/lib/commands/exec.js
Run entire test:
node . run test
Alias Test
alias localnpx="node /workspaces/cli/bin/npx-cli.js"
localnpx --no-install esbuild
References
Fixes #6215