npx
npx copied to clipboard
feature request: use node-module-resolution algorithm when scanning for bins
That is:
If the binary isn't global and can't be find in package-root/node_modules/.bin
then check for parent packages, eg package-root/../node_modules/.bin
.
This would make working in monorepos easier when things like the test client are installed at the top level, but you're inside a sub-project.
This is interesting. I'm a bit worried about it potentially causing serious surprise for people. I'm also wondering about the perf impact, but... I guess we can literally just add every single combination of node_modules/.bin
up the absolute path of the current prefix (in the right order), and let the OS handle it? That might be cool, and would require no extra fs hits for us.
Would you be interested in adding this feature?
literally just add every single combination of node_modules/.bin up the absolute path of the current prefix
This is what I was thinking, yeah.
@zkat
I'v implemented the feature and create a PR https://github.com/zkat/npx/pull/164 several months ago.
Would you please take some time to review it ?
Could we at least add it as a flag --recurseUp
or something? Would be really helpful for monorepo projects.
I recently converted a project to a monorepo with hoisted dependencies and was surprised npx didn't use the module resolution algorithm, so I couldn't use my hoisted dependencies when running npx
inside a specific package's folder. Not the worst thing to work around by any means, but it would be great if #164 or similar was added!
Just trying to share my devDependencies
in a monorepo using npx
and this would allow me to get it to work, getting really tired of managing many packages when they become out of date. This seems like a very logical feature to implement, please can we work out a way to include this to reduce the maintenance burden of upgrading devDependencies
.
@zkat @iarna I am very interested in https://github.com/zkat/npx/pull/164 too, when using lerna in hoisted mode it is pretty essential.
Now npx is part of npm, is this the correct place to have this conversation?