I have recently just started using wsl and zsh for dev purposes and I have tried to add the nvm through as a plugin in zsh through the ~/.zshrc file. I've added, saved and reloaded the terminal several times and tries the nvm command and it comes out with the 'zsh: command not found: nvm' error.
Any suggestions?
You can add nvm's loading script to ~/.zshrc. This instruction can be found on the readme.
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
You can test with:
which node
Hope this works :)
Related
When I run the command source $HOME/.zshrc on Jenkins shell, that runs on a MAC slave, I get the following error in the nvm initialisation:
nvm_err 'N/A: version "N/A -> N/A" is not yet installed.
nvm_err 'You need to run "nvm install N/A" to install it before using it.'
The error does not occurs on local machine, only on jenkins shell. The contents of the .zshrc that crashes is this:
# NVM
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
However, this is the script of the recommended initialisation of nvm, and it is added automatically on nvm installation. Anyone knows what may cause this problem?
I found this article that has an workaround to this problem. This worked for me. In resume, I had just to set the property +ex to make the shell ignore the immediate errors temporarily:
set +ex
source $HOME/.zshrc
set -ex
I've recently switched over to zshrc and every time I load up my terminal, I get this error message:
Last login: Tue Nov 26 12:20:36 on ttys000
complete:13: command not found: compdef
complete:13: command not found: compdef
I looked for other answers/solutions and some posts have hinted at something in the .zshrc file; mine looks like this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
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
Just in case, I also checked my .zprofile file, but it only has this line in it:
source ~/.zshrc
One of the posts that I came across hinted that the problem was in the export NVM section of the .zshrc file, however, I'm not sure how to resolve this. There was one solution that referenced the placement/order of the export NVM.. block in the .zshrc file; am i missing something or have I misplaced/incorrectly ordered something in my .zshrc file?
I'm not sure what is calling complete, but compdef is defined by compinit, so you need to call that first.
autoload -Uz compinit
compinit
# Now you can write code that calls compdef
If you run compinstall, it will add the necessary lines to your .zshrc for you.
I'm using hyper terminal on Windows 10 with WSL(Windows Subsystem for Linux). I've got wsl to default to zsh but whenever I run npm or node i get the "zsh: command not found: node" or npm. To fix this i have to enter "bash" let the terminal switch to bash and then enter "zsh" to switch back. After that node and npm commands work.
Please help! I tried looking at existing posts but didn't find anything relating to this issue.
Thanks for your help in advance!
Just figured it out. Had to add the following in my .zshrc
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_comp$
Although this does make zsh take a long time to load initially.
os: macOS Sierra 10.12.6 (16G29)
terminal app: Hyper 1.3.3.1754
nvm: 0.33.2
I installed nvm, according to the instruction, sometime ago without issue. Recently, it and the commands it's responsible for —node and npm— stopped working.
nvm/npm/node command not found
I realized that this occurred because I recently switched my system default shell from bash to zsh —chsh -s /bin/zsh— without addressing the contents of ~/.bash_profile which is sourced by bash but not zsh.
The nvm install script
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
places the following in the appropriate config file —one of: ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc.
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
At time of install I used bash and that bit was placed in ~/.bash_profile. Coping that content over to ~/.zshrc got the commands working again.
Today was the 1st day of my coding bootcamp and they have us a script that installs all the development cli tools we are gonna use in class. I was using zsh before installing this script and node was working just fine. After running this script none of my previous node, homebrew or any other packages that this script installed works in zsh but they all work in bash. Is there anyway to fix this ?
On windows bash WSL I had to copy this from .bashrc to zshrc based on suggestion by AGDM, but not everything (like with source) or you get a ton of errors. I can finally run npm -v and the usual stuff like npm run start my react app from zsh in vscode.
# npm was not working
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
For node commands via terminal, like npm i <some-cool-npm-jam> --save-dev.
I copied the contents of .bashrc to .zshrc to run the node commands in zsh mode.
Worked flawlessly.