sezna / nps

NPM Package Scripts -- All the benefits of npm scripts without the cost of a bloated package.json and limits of json
MIT License
1.43k stars 93 forks source link

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

Open wmertens opened 5 years ago

wmertens commented 5 years ago

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.

sezna commented 5 years ago

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?

wmertens commented 5 years ago

no, it would be like

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

and from bar you'd be able to run baz

sezna commented 5 years ago

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?