Skip to content
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 version does not persist across new terminal sessions after macOS restart #3315

Closed
holy-chen opened this issue Mar 9, 2024 · 3 comments

Comments

@holy-chen
Copy link

holy-chen commented Mar 9, 2024

Operating system and version:

macOS Sonoma 14.2.1

nvm debug output:

nvm --version: v0.39.5
$TERM_PROGRAM: WarpTerminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'holychan'
${HOME}: /Users/holychan
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.detaspace/bin:${HOME}/.bun/bin:${HOME}/.detaspace/bin:${HOME}/Library/pnpm:${HOME}/.bun/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.9 (x86_64-apple-darwin23.0)'
uname -a: 'Darwin 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64'
checksum binary: 'shasum'
OS version: macOS 14.2.1 23C71
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.4.0 (x86_64-apple-darwin23.0) libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
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.39.3 (Apple Git-145)
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, GNU compatible) 2.6.0-FreeBSD
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:271: command not found: npm
npm root -g: nvm:271: command not found: npm

nvm ls output:

       v16.20.2
       v18.18.0
       v20.11.0
default -> lts/* (-> N/A)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.11.0) (default)
stable -> 20.11 (-> v20.11.0) (default)
lts/* -> lts/iron (-> N/A)
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.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2
lts/hydrogen -> v18.19.1 (-> N/A)
lts/iron -> v20.11.1 (-> N/A)

How did you install nvm?

Homebrew

What steps did you perform?

  1. Open a terminal window.
  2. Use nvm to set a specific Node.js version, e.g., nvm use 14.
  3. Close the terminal window.
  4. Restart the macOS.
  5. Open a new terminal window.
  6. Run node -v.

What happened?

The expected version is not set, and it might show zsh: command not found: node if no default version is set.

What did you expect to happen?

The Node.js version set using nvm use should persist across new terminal sessions, even after restarting the macOS.

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

zshrc

export NVM_DIR="$HOME/.nvm"
    [ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && \. "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" # This loads nvm
    [ -s "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# bun completions

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

@ljharb
Copy link
Member

ljharb commented Mar 9, 2024

Note that nvm isn't supported when installed via homebrew; please use the install script in the readme.

The odd thing I see here is that default points to lts/*, but that points to N/A instead of pointing to lts/iron.

Can you try using latest nvm, v0.39.7?

@holy-chen
Copy link
Author

Of course, I would be very happy to. I will uninstall nvm through homebrew, and then install it in the recommended way; later I will try the latest version of nvm.

@holy-chen
Copy link
Author

I tried not to use homebrew to install nvm, and as we expected, it returned to normal again.

But I still really hope that nvm can support homebrew installation. After all, I don't want to manage my software in multiple places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants