ZSH npm/node/nvm command not found after installing OhMyZSH
After installing OhMyZSH on my Linux machine, previously installed nvm, node and npm are not found. Thanks for the help.
This command "source ~/.nvm/nvm.sh" allows me to make it work, however when I restart terminal or open new tab terminal says that commands are not found... Config '~/.zshrc' file:
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/jurr/.oh-my-zsh"
Solution 1:
Added this line to ./zshrc file. Working great. Original source: https://github.com/lukechilds/zsh-nvm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Solution 2:
I faced the same issue. Details in Gist.
1. Installed nodeJs via nvm using Git Bash
2. Installed hyper terminal & WSL
3. Installed Ubuntu (windows Store) & configured zsh shell.
4. Faced the command not found all over in the zsh shell
5. The same commands are working nicely in the bash shell
Tried sourcing the (node, nvm, npm ) paths in the .zshrc and .profile file & modified the System & Environment Variables in Windows. None of these steps helped me to resolve the issue.
I think the issue is zsh and bash terminals treat things differently. When Installed in bash terminal the default location for the nodeJs in windows will be set to
C:\Users\Program Files\nodejs
The above one is symlinked to C:\Users\<username>\AppData\Roaming\nvm
No matter how much I tried to alias these things in zsh, only node and nvm are working with aliases. npm is failing to locate the necessary lib files.
The only solution that worked for me is Re-installing node in zsh terminal
- Removed the node versions installed via nvm in Bash terminal.
- Removed the nvm in windows via control Panel
- Installed the nvm in the zsh shell
- Installed the node latest LTS version from which npm is also installed.
Post Installing the node via nvm in Zsh I observed the following things.
- Paths for the node, nvm, npm & npx have been automatically added to the $PATH variable
- Node directory is not available neither in
C:\Users\Program Files\nodejs
nor theC:\Users\{username}\AppData\Roaming\nvm
- Instead it is configured differently at
/home/<username>/.nvm/versions/node/v14.15.1/bin/node
This video really helped me in re-installing the node in ZSH: https://www.youtube.com/watch?v=kL8iGErULiw