Reading this I found that it is possible to use zsh inside VSCode so I configured these inside settings.json for my user:
"terminal.integrated.shell.linux": "/usr/bin/zsh",
"terminal.integrated.fontFamily": "'SauceCodePro Nerd Font Mono','Source Code Pro'",
"terminal.integrated.fontSize": 14,
But when I tried to start my Angular app ng serve
, it shows:
zsh: command not found: ng
So following this response that had a similiar issue I added this to the .zshrc file:
if [[ -s '/etc/zsh_command_not_found' ]]; then
source '/etc/zsh_command_not_found'
fi
But now it shows this, and I am not sure that it is the right package to install:
➜ ng serve
No se ha encontrado la orden «ng», pero se puede instalar con:
sudo apt install ng-common
What I can do? Because with bash it works fine.
I found out that I was missing loading nvm in the zshrc file. So I added this to the .zshrc file:
export NVM_DIR="/home/espe/.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
Then I thought someone should have faced this before, and here is an article about how to solve this problem . So the previous code became this:
# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx 2>/dev/null
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
if [ -f "$NVM_DIR/bash_completion" ]; then
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
fi
}
nvm() {
lazynvm
nvm $@
}
node() {
lazynvm
node $@
}
npm() {
lazynvm
npm $@
}
npx() {
lazynvm
npx $@
}
# Add every binary that requires nvm, npm or node to run to an array of node globals
NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)
for cmd in "${NODE_GLOBALS[@]}"; do
eval "${cmd}(){ unset -f ${NODE_GLOBALS} 2>/dev/null; lazynvm; ${cmd} \$@ }"
done
Also, thanks to scttcper , for the improved solution.
Source:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.