Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with hoisted dependencies in monorepos #20

Open
rassie opened this issue May 25, 2022 · 5 comments
Open

Doesn't work with hoisted dependencies in monorepos #20

rassie opened this issue May 25, 2022 · 5 comments

Comments

@rassie
Copy link

rassie commented May 25, 2022

In monorepos, especially managed by lerna or pnpm, npm bin doesn't return the correct binary directory, since a binary can be either hoisted to the root directory of the monorepo or be located in the package's node_modules. Solving this would probably require adding both the monorepo's node_modules/.bin as well package's node_modules/.bin to the path.

@rassie
Copy link
Author

rassie commented Jul 6, 2022

Hmm. It seems to work somewhat correctly if I set add-node-modules-path-command to pnpm bin, since it's also capable of resolving paths in npm and yarn projects.

@texaco
Copy link

texaco commented Sep 10, 2022

This might be easily solved with a recursive function until node_modules does not exists since exec_path admits a list of paths.

@codesuki
Copy link
Owner

Hi! The first implementation actually used to recurse, but we got rid of it due to security concerns: #15

I think if setting add-node-modules-path-command works as @rassie described then this is definitely the way to go.

@forty
Copy link

forty commented Oct 7, 2022

Ideally I would be able to have a list of commands and this would add all the successful results:
For example

(setq add-node-modules-path-commands '("npm bin" "pnpm bin -w"))

This way I could have both binary in the local package and in the workspace package (if any) - and it would work with both npm and pnpm packages with the same config.

@codesuki
Copy link
Owner

I don't have time for it but it sounds useful. If you send a PR I'll look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants