nps icon indicating copy to clipboard operation
nps copied to clipboard

add all node_modules in parent paths to the path (monorepo)

Open wmertens opened this issue 6 years ago • 3 comments

Problem description:

When you use a monorepo, there could be shared tools installed in the repo root and then each package has its own unique dependencies. It would be nice to have them be in path.

Suggested solution:

when creating the PATH variable, walk up the path and add any subdirectories named node_modules/.bin.

wmertens avatar Sep 05 '19 20:09 wmertens

If I understand the problem correctly, this would allow you to run dependencies from project foo when in sibling project bar?

monorepo/
├── foo/
│   ├── node_modules/
│            └──  baz
├── bar/

E.g. running baz from within bar?

sezna avatar Sep 07 '19 18:09 sezna

no, it would be like

monorepo/
├── node_modules/
│            └──  .bin/baz
├── bar/
│       └── node_modules/
│                  └──  stuff

and from bar you'd be able to run baz

wmertens avatar Sep 08 '19 10:09 wmertens

That could introduce ambiguity between bar's modules and monorepo's modules. We could define to use the more local ones preferentially, but I would think that if you have a script inside of bar, the dependencies of that script should also be contained within bar's modules. Is this not desirable in your case?

sezna avatar Sep 11 '19 02:09 sezna