-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Node.js: avoid slow terminal startup time due to nvm #978
Conversation
The version from the nodesource repo was used, but it bricked some systems including mine (broke permissions) so we changed to nvm. |
How about using the snap one? I don't really think nvm is a good choice (especially in terminal loading speed). I tried other method like |
@Botspot What do you think? |
The slow terminal start-up time from So, while I'm open to a better alternative, I don't believe snap is the right option due to its reliably issues. |
Since nodesource and snap is not reliable and stable, I am searching for ways to increase # Defer initialization of nvm until nvm, node or a node-dependent command is
# run. Ensure this block is only run once if .bashrc gets sourced multiple times
# by checking whether __init_nvm is a function.
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type -t __init_nvm)" = function ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh
unset __node_commands
unset -f __init_nvm
}
for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done
fi I got it from here : https://www.growingwiththeweb.com/2018/01/slow-nvm-init.html I will add to the script now. |
Done. @Itai-Nelken @Botspot |
This is a good idea, the problem is that there are much more node dependant commands, and adding all of them makes no sense. |
I did consider this factor, but figured that if someone asks for help we can solve it on a case-by-case basis, reconsidering as necessary going forward. |
Using
nvm
to install nodejs is terrible for me. It slowed down my terminal loading time (there are few issues about this: nvm-sh/nvm#1277, nvm-sh/nvm#1261). Although there are many solution on the web like editing.bashrc
, modifying nvm install script, etc, I don't want to make it so confusing...Then Nodesource does it perfectly.
nvm
, pi-apps will probably hard to update as it need to find out what version of nodejs user have, what is the latest version does nvm have, etc.sudo apt purge nodejs
and remove source list and apt-key. Onnvm
, you will need to delete the folders one-by-one.However, the snap one is also good, but I prefer nodesource since it don't have any dependencies.