-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
build(docs): don't install NPM global deps if they're already installed #12522
build(docs): don't install NPM global deps if they're already installed #12522
Conversation
- use `npm list -g` to check if they're installed first - this exits with error code 1 if it doesn't exist - previously it would unconditionally install, which was unnecessary & inefficient the vast majority of the time - note: that was the purpose of the `/usr/local/bin/` part in the `Makefile`, but this is not universally installed in the same place - can run `npm prefix -g` and concat `/bin/` to that to get the path to your global installs - on my Mac with versioned node (using [`rtx`](https://github.com/jdx/rtx)), the path is: `/Users/<my-user>/.local/share/rtx/installs/node/20.6.0/bin/` - in the `devcontainer` with versioned node (uses `nvm`), I have: `/usr/local/share/nvm/versions/node/v20.5.1/bin` Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
@isubasinghe this might make the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems sensible to me
@agilgur5 The dependency isn't really installed in Nix via a I don't think this is necessarily a negative though, it does make the Makefile more consistent at least. |
Thanks for checking! |
No worries, I don't quite know how it works but I believe it might be due to not assuming a global node installation. I think its a node2nix limitation, really I should replace that tool with raw Nix. |
Ah that would make sense if so. Ideally these shouldn't be globally installed either -- or any of the build deps for that matter -- but we've still got a fair bit of changes necessary before we can get there. |
Motivation
Only install NPM global deps if they're not already installed
make
commands would unconditionally install these global deps, which was unnecessary & inefficient the vast majority of the timeModifications
use
npm list -g
to check if they're installed firstnote: that was the purpose of the
/usr/local/bin/
part in theMakefile
, but this is not universally installed in the same placenpm prefix -g
and concat/bin/
to that to get the path to your global installsrtx
), the path is:/Users/<my-user>/.local/share/rtx/installs/node/20.6.0/bin/
devcontainer
with versioned node (usesnvm
), the path is:/usr/local/share/nvm/versions/node/v20.5.1/bin
Verification