Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

ZSH npm/node/nvm command not found after installing OhMyZSH

Writer Olivia Zamora

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"
2

5 Answers

Added this line to ./zshrc file. Working great. Original source:

export NVM_DIR=~/.nvm [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
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

  1. Removed the node versions installed via nvm in Bash terminal.
  2. Removed the nvm in windows via control Panel
  3. Installed the nvm in the zsh shell
  4. 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.

  1. Paths for the node, nvm, npm & npx have been automatically added to the $PATH variable
  2. Node directory is not available neither in C:\Users\Program Files\nodejsnor the C:\Users\{username}\AppData\Roaming\nvm
  3. 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:

Adding plugin nvm, just edit .zshrc file

plugins=(git nvm)

Close terminal, reopen terminal, hope this solves the problem on your machine too.

Found this solution from this blog post

I was having the same problem after exiting the terminal the nvm command was not found. So to fix this you have to add

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

this line of code on your .zshrc file to do that type vim ~/.zshrc than add the following lines in the bottom and to save the file click ctrl than press :wq! to save file in vim you can also use nano

just add nvm or node in your plugins:

plugins=(git nvm)

reboot ur terminal. Then, good to go

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy