npm/npx

[FEATURE] Monorepo support (standard node bin resolution)

Closed this issue · 1 comments

What / Why

Monorepos hoist certain dependencies to the root of the monorepo. eslint for example may have a single version to avoid installing duplicates or needing to upgrade the version in many places. You are working on changes to a single package and you want to run the monorepo's eslint on the individual package.

When

When you run npx eslint

Where

This only applies to packages that should be found locally
In this example the user runs the command from
my-repo/packages/my-package
and expects to execute
my-repo/node_modules/.bin/eslint

How

now brown cow

Current Behavior

npx considers my-repo/packages/my-package/node_modules/.bin and, failing to find eslint, falls back either to a global bin or to fetching the package.

Expected Behavior

npx considers my-repo/packages/my-package/node_modules/.bin and, failing to find eslint, falls back to my-repo/packages/node_modules/.bin (which doesn't exist), then my-repo/node_modules/.bin (which does), finds the eslint binary and runs it. This is simply the standard node mechanism for resolving packages or binaries.

Who

I don't know that!

References

  • n/a

I'm gonna close this because actually I just forgot that npm itself does this for packages but not binaries...