Search code examples
javascriptnpmvisual-studio-codenvmnpx

vscode wont run nvm packages without me rerunning the .zsh_profile command everytime i restart vscode


I know a lot of other people have had this issue but i cant seem to make it work.

if i dont run these commands in the vscode terminal everytime i open it it wont run npx,npm or 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

i also added these commands to my .zsh_profile and added "terminal.integrated.shellArgs.linux": "-L", to my settings.json folder inside Library/Application Support/Code/User/settings.json

i restarted vscode and npm,nvm,npx still wont run. enter image description here

after that i switched terminal profiles in vscode back to bash and it works to my surprise but other commands like ls find wont work and gives me a weird error so i cant use the bash in my vscode terminal even if i wanted to. enter image description here

any suggestions on what should i do next?


Solution

  • Move the lines to .zshenv in your home directory. This is the place for pre-defined environment variables, it is implicitly sourced in every shell. Create the file if it does not exist.

    The -L parameter is not needed anymore then.