-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
nvm.sh and bash_completion add 2 seconds to shell load time #1774
Labels
performance
This relates to anything regarding the speed of using nvm.
Comments
@andybergon please try this solution #539 (comment) # Install zsh-async if it’s not present
if [[ ! -a ~/.zsh-async ]]; then
git clone git@github.com:mafredri/zsh-async.git ~/.zsh-async
fi
source ~/.zsh-async/async.zsh
export NVM_DIR="$HOME/.nvm"
function load_nvm() {
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
}
# Initialize a new worker
async_start_worker nvm_worker -n
async_register_callback nvm_worker load_nvm
async_job nvm_worker sleep 0.1 |
how about this solution? nvm() {
unset -f nvm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm "$@"
}
node() {
unset -f node
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
node "$@"
}
npm() {
unset -f npm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
npm "$@"
} |
Those don’t allow your globally installed node modules to work prior to first invoking nvm, npm, or node. |
This comment has been minimized.
This comment has been minimized.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Operating system and version:
macOS Sierra 10.12.6
nvm debug
output:I don't think it is relevant for this issue but here it is.
nvm ls
output:I don't think it is relevant for this issue but here it is.
How did you install
nvm
? (e.g. install script in readme, Homebrew):Install script in README. (I thought brew installation was not supported as stated in the docs)
What steps did you perform?
I added the following to my
.bashrc
file.(I know bash_completion will probably work only with bash and I know I can install nvm as a zsh plugin but I change shell sometimes)
With those 2 lines enabled:
Without those 2 lines:
So the startup of a shell (zsh in my case) was slowed down by ~2 seconds adding those 2 lines.
I expected the loading to be faster or at least that the time it adds to be in the docs as it is significant.
(Thanks for your work!)
The text was updated successfully, but these errors were encountered: