MacOS error for every new session: zsh: command not found: node
mikima opened this issue · comments
Operating system and version:
MacOS Sonoma 14.4.1 (23E224)
How did you install nvm
?
Install script in readme
What steps did you perform?
installed NVM. Everything works fine: installed and used node.
What happened?
When i close the terminal and open a new session, node
and npm
command are not available. It says:
zsh: command not found: node
first I have always to run nvm run node
, and then i can use node and npm.
I'm pretty sure on my previous computer I didn't had to do that.
What did you expect to happen?
To be able to run node and npm without having to call nvm first all the times
Is there anything in any of your profile files that modifies the PATH
?
I have an empty .zshrc
file.
Seems like the install script didn't install the sourcing lines in your profile file correctly.
If you manually add the lines shown here to .zshrc
, I would expect the problem to be resolved.
Additionally, nvm alias default node
will ensure that the latest installed version will be the default on a new shell.
Hi! Thank you for suggestion, but still i'm having the same issue.
i re-installed NVM using
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
and now my .zshrc
looks like this:
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
EDIT fixed error
ok, fixed by manually changing .zshrc
by removing the line added by install script and changing with the one in the NVM readme:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
to be clear, nvm alias default node
doesn't reinstall nvm, it just tells the existing nvm to set the "default" alias to "node".
Your OP claimed you had an empty zshrc, but somehow you ended up with two sets of nvm lines - one from an old version, and one from latest. The one you have now is from latest.
hi @ljharb , sorry you're right. I copied the wrong command in the comment and the wrong zshrc :/
Now I updated it