nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NVM just will not change version of node

RUSHt opened this issue · comments

Operating system and version:

macOC Sonoma 14.3

nvm debug output:

nvm --version: v0.39.7
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: 'peteralderson'
${HOME}: /Users/peteralderson
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin:${NVM_DIR}/versions/node/v16.20.2/bin:/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.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64'
checksum binary: 'shasum'
OS version: macOS 14.3 23D56
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.58.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: /opt/homebrew/bin/git, git version 2.35.1
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: system
which node: /opt/homebrew/bin/node
which iojs: iojs not found
which npm: /opt/homebrew/bin/npm
npm config get prefix: /opt/homebrew
npm root -g: /opt/homebrew/lib/node_modules

nvm ls output:

How did you install nvm?

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bas

What steps did you perform?

nvm install 16.20.2
v16.20.2 is already installed.
Now using node v16.20.2 (npm v10.2.4)
nvm use 16.20.2
Now using node v16.20.2 (npm v10.2.4)
node --version
v21.6.1
nvm alias default 16.20.2
default -> 16.20.2 (-> v16.20.2)

What happened?

No change in node version

What did you expect to happen?

Node version change to 16.20.2

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

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

Can you fill out the rest of the issue template?

Specifically, the PATH question. I suspect homebrew is initialized after nvm, which means homebrew’s node will always preempt nvm’s.

I'm not sure how to answer the path question, is there a file I can attach with the information required ?

Don't just attach your shell profile files, but look in ~/.zshrc or ~/.zprofile, and confirm that the nvm-related lines occur after any homebrew-related lines.

Additionally, you can try removing the brew-installed node.

I have placed...

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

At the end of ~./zshrc, exit shell & then restart, and it's still the same.

I would not have installed node using brew.

(Sorry, but I must be missing something)

Your nvm debug output includes which node: /opt/homebrew/bin/node

That was it. I must have used brew install node, even though my preference is to use nvm.

Thanks for you help.

Closing...

Glad you figured it out!