Ensure npm run is being called instead of npx run
#245
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.
Problem:
If you run
npm-run-allusingnpx(EX:npx npm-run-all clean build:dev test), it will prompt you to installrunjsif it is not already installed.Then, it will throw an error that looks something like this:

This is because running
npx npm-run-allcausesprocess.env.npm_execpathto point tonpxinstead ofnpm.The underlying command ends up something like
npx run cleanwhich will attempt to runrunjsinstead of running the npm scripts, and of course,cleanisn't a javascript file or anything thatrunjscan do anything with, so that is why it throws.For reference, this is what it looks like when I intentionally run

runjsin place ofnpm run.If you look here at run.js, you can see the code that is being unintentionally ran by
npm-run-all.I am pretty sure this problem is related to #196. The error looks to be exactly the same, and on my machine,


yarnaliases tonpx yarnwhich would causeyarnto throw an error wherenpmwould work fine.yarn:
npm:
Testing:
I went ahead and ran the automated tests in GH actions, and all the of the current tests look like they pass with these changes. It might make sense to introduce a test for running
npm-run-allusingnpx, and maybe, even one for runningyarnwithnpx.[UPDATE]: not sure why AppVeyor tests failed (I mean, the tests didn't even run, they just crapped out before they started). The error does not seem to be related to my changes at all, so idk 🤷♀️ I'm looking into it, but if someone knows, I would love clarification.
[2ND UPDATE]: It seems that the same error is happening in other PRs which don't even touch the code:
EX: #216 => https://ci.appveyor.com/project/mysticatea/npm-run-all/builds/41262284
This PR only touches a markdown file, so it looks like the App Veyor PR test doesn't work anymore which is not super suprising since the last commit was 3 years ago.
Additional Information
I also modified how yarn is detected because I modified
npmPath(which was how yarn was being detected previously). Before,isYarnwas false whennpxwas used in conjunction withyarn. With these changes, it should actually detect yarn even if you runyarnusingnpx. (EXnpx yarn dev)before:


after: