nvm-sh/nvm

sourcing .zshrc is changing nvm node version to system node ignoring set defaults

JonahMoses opened this issue · 10 comments

screen shot 2018-01-08 at 12 07 11 am

I do not have a .npmrc and the following lines are in my .zshrc file:
export PATH="~/.yarn/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

Can you share the rest of your .zshrc?

```sh export PATH="~/.yarn/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

Would you like to use another custom folder than $ZSH/custom?

ZSH_CUSTOM=~/.dotfiles/custom

See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

ZSH_THEME="TheOne"

plugins=()

export ZSH=/Users/jonahmoses/.oh-my-zsh
source $ZSH/oh-my-zsh.sh

show contents of directory after cd-ing into it

chpwd() { l }

Colors

autoload -U colors
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
colors

Use vim as the visual editor

export VISUAL=vim
export EDITOR=vim

Save a ton of history

setopt hist_ignore_all_dups inc_append_history
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=5000

FZF & RipGrep

[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --glob "!{.git,node_modules}/*" 2> /dev/null'

fpath=(/usr/local/share/zsh-completions $fpath)

source ~/.dotfiles/aliases.zsh
source ~/.dotfiles/prompt.zsh

source nvm

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

</details>

Thanks - what about aliases.zsh and prompt.zsh?

prompt.zsh

```sh setopt prompt_subst

autoload -Uz vcs_info

zstyle ':vcs_info:' enable git
zstyle ':vcs_info:
' stagedstr 'M'
zstyle ':vcs_info:' unstagedstr 'M'
zstyle ':vcs_info:
' check-for-changes true
zstyle ':vcs_info:' actionformats '%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:
' formats
'%F{5}[%F{2}%b%F{5}] %F{2}%c%F{3}%u%f'
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] &&
git status --porcelain | grep '??' &> /dev/null ; then
hook_com[unstaged]+='%F{1}??%f'
fi
}

precmd () { vcs_info }
PROMPT='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_} %fॐ '

</details>

aliases.zsh

```sh # Other alias v='vim' alias vi='vim' alias be='bundle exec' alias bu='bundle update' alias bi='bundle install' alias reload='source ~/.dotfiles/.zshrc' alias sane='stty sane' alias ll='ls -al'

Movement

alias ..='cd ..'
alias ~='cd ~'
alias .f='cd ~/.dotfiles'
alias vrc='vim ~/.vimrc'
alias zrc='vim ~/.zshrc'
alias trc='vim ~/.tmux.conf'
alias aliases='vim ~/.dotfiles/aliases.zsh'
alias plugins='vim ~/.dotfiles/.vim/plugins.vim'
alias coding='cd ~/coding'

#RipGrep
alias rg='rg --ignore-case --no-heading'

Git

alias gh="git log --pretty=format:'%h - %ad (%ar) - [%an] : %s' --date=short --graph --since=5.months"
alias gs='git status'
alias g='git'
alias gb='git branch'
alias push='git push'
alias pull='git fetch && git pull'
alias ga='git add -A :/'
alias gbx='git branch -D'
alias gbc='git checkout -b'
alias gco='git checkout'
alias master='git checkout master'
alias gca='git commit --amend'
alias diff='git diff | gitx'
gcm() { git commit -m "$*" }

Tmux

alias tns='tmux new -s'
alias tat='tmux attach -t'
alias tls='tmux list-sessions'
alias tks='tmux kill-session -t'

Spelling

alias zues='zeus'
alias alaises='aliases'

</details>

hmm, nothing strange there :-/

If from bash, you do nvm deactivate before sourcing .zshrc, what happens?

My default shell is zsh so I'm never in bash land. However if I switch to bash with exec bash then nvm deactivate I get a nvm command not found

ok, so then in zsh prior to sourcing zshrc, if you do nvm deactivate, and then source zshrc :-)

Either that or adding PATH="/usr/local/bin:$(getconf PATH)" to the top of my .zshrc file seemed to fix it

tflx commented

Thank you!...The PATH thing fixed it for me. Been struggling with this.