nvm icon indicating copy to clipboard operation
nvm copied to clipboard

when reopen terminal and node\npm\yarn are not available

Open liuzongyang255 opened this issue 2 years ago • 3 comments

Operating system and version:

macOS 13.1

nvm debug output:

~ %npm
zsh: command not found: npm
~ %

nvm ls output:

~ %nvm ls
       v16.13.2
default -> 16.13.2 (-> v16.13.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.13.2) (default)
stable -> 16.13 (-> v16.13.2) (default)
lts/* -> lts/hydrogen (-> 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.2 (-> N/A)
lts/gallium -> v16.19.0 (-> N/A)
lts/hydrogen -> v18.12.1 (-> N/A)

How did you install nvm?

install script in Homebrew

What steps did you perform?

install nvm and node in one zsh window and use npm in another zsh window

What happened?

~ %npm
zsh: command not found: npm
~ %

What did you expect to happen?

show the npm help scripts

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

no

liuzongyang255 avatar Jan 05 '23 02:01 liuzongyang255

(note that installing nvm via homebrew is unsupported; please install it with the only proper method, the install cript in the readme)

Once nvm is installed, you need to close and reopen your terminal to use it (or, open a new one). At that point, nvm is installed, but node and npm are not - you need to nvm install node (or nvm install 12, or whatever) first.

yarn does not ship with node and would only be available if you installed it yourself.

ljharb avatar Jan 05 '23 06:01 ljharb

solved this issue by reset PATH:

export PATH=$PATH:/Users/leo/.nvm/versions/node/v16.13.2/bin

liuzongyang255 avatar Jan 05 '23 09:01 liuzongyang255

@liuzongyang255 that's not solving it, and that's going to guarantee nvm can't work properly. nvm alias default 16 would be sure it's set as the default, though.

ljharb avatar Jan 05 '23 19:01 ljharb

This command solves my problem nvm alias default 16 where 16 can be replaced by the desired version like 16.19.0 or another.

Diboby avatar Feb 07 '23 23:02 Diboby

This seems answered.

ljharb avatar Feb 07 '23 23:02 ljharb