nvm: NVM Use Default does not persist - macos with zsh

Operating system and version:

macOS Big Sur

nvm debug output:

nvm --version: v0.37.0
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'joshuasherman'
${HOME}: /Users/joshuasherman
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/opt/mongodb-community@4.2/bin:/usr/local/opt/mongodb-community@4.0/bin:/usr/local/opt/mongodb-community@4.2/bin:/usr/local/opt/mongodb-community@3.6/bin:/usr/local/opt/rabbitmq/sbin:${NVM_DIR}/versions/node/v14.11.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/opt/rabbitmq/sbin:/usr/local/opt/rabbitmq/sbin:${HOME}/.local/bin:${HOME}/.local/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8 (x86_64-apple-darwin20.0)'
uname -a: 'Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64'
checksum binary: 'shasum'
OS version: macOS 11.6 20G165
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
wget: not found
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.30.1 (Apple Git-130)
ls: grep:: No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: v14.11.0
which node: ${NVM_DIR}/versions/node/v14.11.0/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v14.11.0/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v14.11.0
npm root -g: ${NVM_DIR}/versions/node/v14.11.0/lib/node_modules

nvm ls output:

       v10.22.1
       v10.23.0
       v12.19.1
       v12.20.0
       v12.20.1
       v12.21.0
       v12.22.0
       v12.22.1
       v12.22.4
       v12.22.6
       v14.10.1
->     v14.11.0
       v14.12.0
       v14.13.0
       v14.13.1
       v14.14.0
       v14.15.0
       v14.15.1
       v14.18.0
       v14.18.1
       v14.18.2
        v15.0.0
        v15.0.1
        v15.2.1
        v16.8.0
       v16.10.0
       v16.13.0
        v17.0.0
default -> 14.18.2 (-> v14.18.2)
node -> stable (-> v17.0.0) (default)
stable -> 17.0 (-> v17.0.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.13.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7 (-> N/A)
lts/fermium -> v14.18.2
lts/gallium -> v16.13.0

How did you install nvm?

curl

What steps did you perform?

nvm alias default 14.18.2 nvm use default then open a new terminal tab node --version and it is still 14.11.0

What happened?

does not persist default

What did you expect to happen?

14.18.2 should be the default version

Is there anything in any of your profile files that modifies the PATH?

I have this in my .zshrc

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (15 by maintainers)

Most upvoted comments

same bug here.

so frustrating.

I did use nvm alias default 18.13.0, but still node -v shows it’s node14.

so, yeah, maybe i will have to add nvm use default in zshrc

Hey guys, I’ll join the conversation as I started experiencing something similar after upgrading to Monterey on mac. In my case I only have one version installed and when I boot up, node and all related commands are not found and nvm ls gives: Screenshot 2021-12-02 at 09 54 45

Running nvm_find_nvmrc logs nothing Running nvm use system && nvm_auto && nvm current outputs: System version of node not found.

Basically I just added nvm use default to .zshrc as a temporary fix

UPDATE:

Ok, I seemed to resolve the issue by re-installing xcode-select and nvm 👍

granted this is not really a big deal, I just have to remember to nvm use default whenever I start, but still, it would be nice if it persisted, thanks

yes i can confirm that reinstalling nvm solves the issue on mac os 13 ventura and zsh

@NodeGuy you don’t have a default version set. “(default)” there means it’s a default/built-in alias. Try nvm alias default node.

Thanks for checking.

Is there anything in any of your profile files that hardcodes the PATH to have 14.11 in it?