Closed tabrindle closed 6 years ago
For whatever reason, when I run npx cordova
the order appears to be global => local
, but in my case I'd prefer local. The ability to specify hierarchy when running commands makes sense to me.
Imo the order should be local => global
, i.e. a locally installed version of the module should be favored even if a global is available. I also think the ability to specify the order that you want, or something like --prefer-global
or --prefer-local
would be very useful.
Hi! So what you're seeing here is a manifestation of a problem that I believe is really npm's: the fact that transitive dependencies have their binaries installed at the top level of the project. This is a pretty significant gotcha, and while npx is particularly vulnerable to it, it's the exact same problem you can run into when using npm run-script
.
This turns out to be a duplicate of #127, and is linked to npm issue https://github.com/npm/npm/issues/18874, so I'm going to close this specific issue, but we can keep discussing it in one of the other places! Thanks for filing the issue: I'd definitely like to have this weird corner case fixed, myself.
Hey! Just want to start out by saying this project is amazing, and I frequently tell anyone who is willing to listen about it, and how it will solve all their problems. #panacea
That being said, I frequently recommend this project in the context of my envinfo project which aims to make debugging environment related problems a bit easier. It's already in React Native, and about to be in a bunch of other projects like CRA.
The standard output looks like this:
npx envinfo
I recently ran into an issue which isn't really your fault, but might be a good feature request. In one project, I ran into this: npm: 2.15.12
Wait, wut? It turns out one of the dependencies in this project inexplicably has npm@2 as a dependency, and thus npx picks this up as the installation of npm, and prints its version out, even though 5.5.1 is installed globally.
So what that brings us to is a couple things.
--prefer-global
flag in npx? Your current hierarchy of which binary to run seems to be local => global => shell? (cache in there somewhere) but it would be excellent to be able to specify which to prefer. Sometimes with npx peeps may prefer a native shell solution first, then global, then local, or some combination.Thanks!