nvm
nvm copied to clipboard
Set the default version of node, but the default version of node fails and can only be used in the current terminal
Operating system and version:
How did you install nvm?
Download via Manjaro Linux's package manager
What steps did you perform?
What happened?
Set the default version of node, but the default version of node fails and can only be used in the current terminal
What did you expect to happen?
Switching successful
If you installed via manjaro's package manager, you're using an unsupported installation mechanism. Please uninstall, and install with the only official mechanism - the install script - and if it's still failing, I'll be happy to reopen this.
If you installed via manjaro's package manager, you're using an unsupported installation mechanism. Please uninstall, and install with the only official mechanism - the install script - and if it's still failing, I'll be happy to reopen this.
I have now deleted the nvm I downloaded through the manjaro package manager. Then I used nvm by downloading the description of nvm-sh from github, and then I downloaded some node versions I used before, and then switched the default version as shown below
great. can you also please fill out the full issue template? It's there for a reason.
great. can you also please fill out the full issue template? It's there for a reason.
I checked and found all the parts I know. For example, the nvm version, but I don't know the steps that lead to this result. If there are any parts that are not clear, please point them out and I will fill them in immediately.
In particular, the curl command, nvm debug, the questions about your shell profile, etc. Can you please update the OP with that information? You can copy-paste it out of a "new issue" tab.
In particular, the curl command,
nvm debug, the questions about your shell profile, etc. Can you please update the OP with that information? You can copy-paste it out of a "new issue" tab.
Ok, I will create a new issue and fill in the details
Please don't actually create a new one - just update this one with the template from a pending new issue.
Please don't actually create a new one - just update this one with the template from a pending new issue.
Sorry, I misunderstood your meaning.
Operating system and version:
nvm debug output:
nvm --version: v0.40.3
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'zlw'
${HOME}: /home/zlw
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.local/share/pnpm::${HOME}/.pyenv/shims:${HOME}/bin:/usr/lib/jvm/default/bin:${HOME}/bin:/usr/lib/jvm/default/bin:${NVM_DIR}/versions/node/v20.12.2/bin:${HOME}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/dart-sdk/bin:/usr/lib/go/bin:${HOME}/go/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:${HOME}/Android/Sdk/platform-tools:${HOME}/.pub-cache/bin:${HOME}/go/bin:${HOME}/git.kicad99.com/bfdx/:/usr/lib/go/bin:${HOME}/go/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:${HOME}/Android/Sdk/platform-tools:${HOME}/.pub-cache/bin:${HOME}/go/bin:${HOME}/git.kicad99.com/bfdx/
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash,版本 5.2.37(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 6.12.28-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri, 09 May 2025 10:53:27 +0000 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: {PRETTY_NAME} ()
awk: /usr/bin/awk, GNU Awk 5.3.2, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.2, GNU MP 6.3.0)
curl: /usr/bin/curl, curl 8.13.0 (x86_64-pc-linux-gnu) libcurl/8.13.0 OpenSSL/3.5.0 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.65.0 nghttp3/1.9.0
wget: /usr/bin/wget, GNU Wget 1.25.0 在 linux-gnu 上编译。
git: /usr/bin/git, git version 2.49.0
grep: /usr/bin/grep, grep (GNU grep) 3.12-modified
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.7
basename: /usr/bin/basename, basename (GNU coreutils) 9.7
rm: /usr/bin/rm, rm (GNU coreutils) 9.7
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.7
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.10.0
nvm current: v20.12.2
which node: ${NVM_DIR}/versions/node/v20.12.2/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v20.12.2/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v20.12.2
npm root -g: ${NVM_DIR}/versions/node/v20.12.2/lib/node_modules
nvm ls output:
v14.20.0
v16.20.2
v18.18.2
-> v20.12.2
system
default -> v20.12.2
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.12.2) (default)
stable -> 20.12 (-> v20.12.2) (default)
lts/* -> lts/jod (-> 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.20.8 (-> N/A)
lts/iron -> v20.19.2 (-> N/A)
lts/jod -> v22.16.0 (-> N/A)
How did you install nvm?
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
What steps did you perform?
nvm alias default v18.18.2 nvm use default
What happened?
The current terminal successfully switches the node version, but when a new terminal is created, the node version is still the original version
What did you expect to happen?
The default version of the system node uses the version just switched, and each terminal also uses the node version just switched
Is there anything in any of your profile files that modifies the PATH?
I created a .profile in ~, and set my environment configuration in it. After I downloaded nvm through curl, I set it in .profile:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Then I source ~/.profile in .zshrc
Please don't actually create a new one - just update this one with the template from a pending new issue.
nvm alias default v18.18.2 nvm use default
After executing these two lines, you can view the first two pictures by running nvm ls
ok, so it sounds like the issue is that when you open a new terminal, it's not using the default value? but nvm is actually available?
What exactly happens when you open a new terminal, and type nvm ls?
ok, so it sounds like the issue is that when you open a new terminal, it's not using the default value? but nvm is actually available?
What exactly happens when you open a new terminal, and type
nvm ls?
When I use nvm alias default v18.18.2 and then use default, the nvm ls of the new terminal is as follows:
v14.20.0
v16.20.2
v18.18.2
-> v20.12.2
system
default -> v18.18.2
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.12.2) (default)
stable -> 20.12 (-> v20.12.2) (default)
lts/* -> lts/jod (-> 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.20.8 (-> N/A)
lts/iron -> v20.19.2 (-> N/A)
lts/jod -> v22.16.0 (-> N/A)
ok, that suggests there's something in your profile files that's setting node 20 explicitly. Can you share the contents of your profile files?
ok, that suggests there's something in your profile files that's setting node 20 explicitly. Can you share the contents of your profile files?
I checked and there is no setting. You can check if there is any that will affect it.
# set go environment
export GOROOT=/usr/lib/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
# set proxy
export GOPROXY=https://goproxy.cn,direct
export GOSUMDB=off
export GO111MODULE=on
___MY_VMOPTIONS_SHELL_FILE="${HOME}/.jetbrains.vmoptions.sh"; if [ -f "${___MY_VMOPTIONS_SHELL_FILE}" ]; then . "${___MY_VMOPTIONS_SHELL_FILE}"; fi
# Added by Toolbox App
export PATH="$PATH:/home/zlw/.local/share/JetBrains/Toolbox/scripts"
export PUB_HOSTED_URL="https://pub.flutter-io.cn"
export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
# flutter
export FLUTTER_HOME=/opt/flutter
export PATH=$PATH:$FLUTTER_HOME/bin
export PUB_HOSTED_URL="https://pub.flutter-io.cn"
export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
export ANDROID_HOME=/home/zlw/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=/usr/lib/jvm/default
export PATH=$JAVA_HOME/bin:$PATH
alias google-chrome='google-chrome-stable'
export PATH=$HOME/bin:$PATH
export PATH="$PATH:$HOME/.pub-cache/bin"
export PATH="$PATH:$HOME/go/bin"
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
export PATH="$PATH:$HOME/git.kicad99.com/bfdx/"
[[ -s "/home/zlw/.gvm/scripts/gvm" ]] && source "/home/zlw/.gvm/scripts/gvm"
export PNPM_HOME=/home/zlw/.local/share/pnpm
export PATH=:/home/zlw/.pyenv/shims:/home/zlw/bin:/usr/lib/jvm/default/bin:/home/zlw/bin:/usr/lib/jvm/default/bin:/home/zlw/.nvm/versions/node/v20.12.2/bin:/home/zlw/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/dart-sdk/bin:/usr/lib/go/bin:/home/zlw/go/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:/home/zlw/Android/Sdk/platform-tools:/home/zlw/.pub-cache/bin:/home/zlw/go/bin:/home/zlw/git.kicad99.com/bfdx/:/usr/lib/go/bin:/home/zlw/go/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:/home/zlw/Android/Sdk/platform-tools:/home/zlw/.pub-cache/bin:/home/zlw/go/bin:/home/zlw/git.kicad99.com/bfdx/
export PNPM_HOME=/home/zlw/.local/share/pnpm
export PATH=/home/zlw/.local/share/pnpm::/home/zlw/.pyenv/shims:/home/zlw/bin:/usr/lib/jvm/default/bin:/home/zlw/bin:/usr/lib/jvm/default/bin:/home/zlw/.nvm/versions/node/v20.12.2/bin:/home/zlw/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/dart-sdk/bin:/usr/lib/go/bin:/home/zlw/go/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:/home/zlw/Android/Sdk/platform-tools:/home/zlw/.pub-cache/bin:/home/zlw/go/bin:/home/zlw/git.kicad99.com/bfdx/:/usr/lib/go/bin:/home/zlw/go/bin:/home/zlw/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:/home/zlw/Android/Sdk/platform-tools:/home/zlw/.pub-cache/bin:/home/zlw/go/bin:/home/zlw/git.kicad99.com/bfdx/
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Which file is that from? Do you have any other relevant profile files?
Which file is that from? Do you have any other relevant profile files?
This profile is used to configure some information of the terminal. I added some configuration to the profile and then executed source ~/.profile in .zshrc. There is no other configuration about nvm or node in the system.
Why zshrc? Everything you’ve provided indicates you’re using bash.
Why zshrc? Everything you’ve provided indicates you’re using bash.
The same is true for bash, but my system terminal uses zsh by default, and .bashrc is also processed in the same way
zsh shouldn't load bashrc, though - are you saying that your zshrc and bashrc are identical? or that both source the .profile file?
What happens if you nvm unalias default, and then open up a new terminal, and nvm debug?
i meet the same question. 'set default' works when 'nvm ls' show the list, however when i open a new terminal tab 'node -v' show the wrong version. i tried brew and git to install it, both behave the same problem.
zsh shouldn't load bashrc, though - are you saying that your zshrc and bashrc are identical? or that both source the .profile file?但是,zsh 不应该加载 bashrc - 你是说你的 zshrc 和 bashrc 相同吗?还是两者都来源于 .profile 文件?
What happens if you
nvm unalias default, and then open up a new terminal, andnvm debug?如果您使用nvm unalias default,然后打开一个新终端并执行nvm debug,会发生什么情况?
Sorry! I was very busy last week and forgot to continue discussing this issue with you.
Regarding the two terminals, zsh and bash, I just applied some common configurations. Some different configurations are still in .zshrc or .bashrc.
nvm unalias default:
Deleted alias default - restore it with `nvm alias "default" "v20.12.2"`
nvm debug:
nvm --version: v0.40.3
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'zlw'
${HOME}: /home/zlw
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.local/share/pnpm::${HOME}/.pyenv/shims:${HOME}/bin:/usr/lib/jvm/default/bin:${HOME}/bin:/usr/lib/jvm/default/bin:${NVM_DIR}/versions/node/v20.12.2/bin:${HOME}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/dart-sdk/bin:/usr/lib/go/bin:${HOME}/go/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:${HOME}/Android/Sdk/platform-tools:${HOME}/.pub-cache/bin:${HOME}/go/bin:${HOME}/git.kicad99.com/bfdx/:/usr/lib/go/bin:${HOME}/go/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts:/opt/flutter/bin:${HOME}/Android/Sdk/platform-tools:${HOME}/.pub-cache/bin:${HOME}/go/bin:${HOME}/git.kicad99.com/bfdx/
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash,版本 5.2.37(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 6.12.28-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri, 09 May 2025 10:53:27 +0000 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: {PRETTY_NAME} ()
awk: /usr/bin/awk, GNU Awk 5.3.2, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.2, GNU MP 6.3.0)
curl: /usr/bin/curl, curl 8.13.0 (x86_64-pc-linux-gnu) libcurl/8.13.0 OpenSSL/3.5.0 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.65.0 nghttp3/1.9.0
wget: /usr/bin/wget, GNU Wget 1.25.0 在 linux-gnu 上编译。
git: /usr/bin/git, git version 2.49.0
grep: /usr/bin/grep, grep (GNU grep) 3.12-modified
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.7
basename: /usr/bin/basename, basename (GNU coreutils) 9.7
rm: /usr/bin/rm, rm (GNU coreutils) 9.7
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.7
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.10.0
nvm current: v20.12.2
which node: ${NVM_DIR}/versions/node/v20.12.2/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v20.12.2/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v20.12.2
npm root -g: ${NVM_DIR}/versions/node/v20.12.2/lib/node_modules
In addition, I set the default node version and switched it before (about 1-3 months?) and everything was normal. I don’t know when it failed after the update or something else. However, I have also updated the related operations of nvm, so I will not modify its code.
hmm, based on that last comment, the default was set to node 20, not node 18, and node 20 was the version being used.
any solution ? meet the same issue
Both are zsh, the same issue of switching node versions only exists in the current terminal, and it will become invalid the next time the terminal is opened
any solution ? meet the same issue
According to the previous communication process with the author, the author always thinks that my configuration is wrong. But I think my configuration is fine, so I didn't use nvm, and now I'm using other management tools
That was only the first time - the last interaction was https://github.com/nvm-sh/nvm/issues/3596#issuecomment-2994844237, which seems to imply the issue is resolved, but you never replied to it.
Since you're not using nvm, I'll close this; if someone else has a similar issue, please file a new one and fill out the issue template.