nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.62k stars 7.97k forks source link

Opening a new terminal cannot find the previously set node #3129

Closed danielesk closed 2 months ago

danielesk commented 1 year ago

Operating system and version:

nvm debug output:

nvm --version: v0.39.3 $SHELL: /usr/bin/zsh $SHLVL: 1 whoami: 'huawei' ${HOME}: /home/huawei ${NVM_DIR}: '${HOME}/.nvm' ${PATH}: ${HOME}/.g/bin:${HOME}/.g/go/bin:${NVM_DIR}/versions/node/v18.16.0/bin:${HOME}/.sdkman/candidates/maven/current/bin:${HOME}/.sdkman/candidates/java/current/bin:${HOME}/.g/bin:${HOME}/.g/go/bin:${HOME}/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:${HOME}/.local/share/JetBrains/Toolbox/scripts:${HOME}/.cargo/bin $PREFIX: '' ${NPM_CONFIG_PREFIX}: '' $NVM_NODEJS_ORG_MIRROR: 'https://npmmirror.com/mirrors/node/' $NVM_IOJS_ORG_MIRROR: '' shell version: 'zsh 5.7.1 (x86_64-debian-linux-gnu)' uname -a: 'Linux 5.10.0-amd64-desktop #20.00.52.02-release SMP Wed Jun 8 17:30:51 CST 2022 x86_64 GNU/Linux' checksum binary: 'sha256sum' OS version: UnionTech OS GNU/Linux 20 awk: /usr/bin/awk, GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) curl: /usr/bin/curl, curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 wget: /usr/bin/wget, GNU Wget 1.20.1 built on linux-gnu. git: /usr/bin/git, git version 2.20.1 ls: cannot access '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 (GNU grep) 3.3 sed: /usr/bin/sed, sed (GNU sed) 4.7 cut: /usr/bin/cut, cut (GNU coreutils) 8.30 basename: /usr/bin/basename, basename (GNU coreutils) 8.30 rm: /usr/bin/rm, rm (GNU coreutils) 8.30 ls: cannot access 'mkdir:': No such file or directory mkdir: mkdir: aliased to nocorrect mkdir (nocorrect mkdir), mkdir (GNU coreutils) 8.30 xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0.225-235f nvm current: v18.16.0 which node: ${NVM_DIR}/versions/node/v18.16.0/bin/node which iojs: iojs not found which npm: ${NVM_DIR}/versions/node/v18.16.0/bin/npm npm config get prefix: ${NVM_DIR}/versions/node/v18.16.0 npm root -g: ${NVM_DIR}/versions/node/v18.16.0/lib/node_modules ```sh ```

nvm ls output:

v16.20.0 -> v18.16.0 default -> v16.18.0 (-> N/A) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v18.16.0) (default) stable -> 18.16 (-> v18.16.0) (default) lts/* -> lts/hydrogen (-> v18.16.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.12 (-> N/A) lts/fermium -> v14.21.3 (-> N/A) lts/gallium -> v16.20.0 lts/hydrogen -> v18.16.0 ```sh ```

How did you install nvm?

Git Install

What steps did you perform?

What happened?

When I open a terminal and set it up with the command node use --lts and then type node -v, I get the output, but when I open a new terminal and execute node -v it says zsh: command not found: node.

What did you expect to happen?

I should be able to output the version information when I enter the new terminal, because the node version was set before that

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

Here's some of the information I've configured myself

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

```sh ```
ljharb commented 1 year ago

node use --lts isn't a thing; do you mean nvm use --lts?

If so, use is only ever for the life of the shell session. You want nvm alias default lts/*, for example, if you want the latest LTS version to be the default.