admin管理员组文章数量:1122846
I have a new mac setup on apple silicon (M2). I've installed homebrew, nvm, and pnpm via the mac terminal (zsh) and added all to path, and have verified the installations by typing nvm -v
command etc.
However, the terminal in VS Code gives me command not found
error for all:
When I type echo $PATH
the path variables are the same in both terminals. What can I do to allow vs code to find these installed packages?
I have a new mac setup on apple silicon (M2). I've installed homebrew, nvm, and pnpm via the mac terminal (zsh) and added all to path, and have verified the installations by typing nvm -v
command etc.
However, the terminal in VS Code gives me command not found
error for all:
When I type echo $PATH
the path variables are the same in both terminals. What can I do to allow vs code to find these installed packages?
1 Answer
Reset to default 01. Ensure VS Code Is Using Your Default Shell
- Open VS Code.
- Go to Settings (Cmd + , or File > Preferences > Settings).
- Search for terminal.integrated.defaultProfile.osx (or terminal.integrated.shell.osx for older versions of VS Code).
- Ensure the default profile is set to zsh:
{ "terminal.integrated.defaultProfile.osx": "zsh" }
If the setting does not exist, add the following to your settings.json file:
{ "terminal.integrated.defaultProfile.osx": "zsh" }
Restart the VS Code terminal to apply the changes.
2. Ensure Environment Variables Are Loaded
For macOS, environment variables defined in your shell configuration files (like .zshrc) may not be loaded in VS Code's integrated terminal. To fix this:
- Open your ~/.zshrc file:
nano ~/.zshrc
- Ensure you have the necessary exports for nvm, pnpm, and Homebrew:
export PATH="/opt/homebrew/bin:$PATH" # Homebrew
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion"
export PATH="$HOME/.pnpm:$PATH" # pnpm
- Reload your shell configuration:
source ~/.zshrc
- Restart VS Code to load the updated environment.
3. Load the Shell Environment for GUI Applications
macOS doesn’t always load the same shell configuration for GUI applications like VS Code. To fix this:
Create or edit the ~/.zprofile file:
nano ~/.zprofile
Add the following to load your .zshrc for GUI apps:
if [ -f ~/.zshrc ]; then source ~/.zshrc fi
Save the file and restart VS Code.
4. Check the VS Code Terminal Profile adf
Open the VS Code integrated terminal.
Type:
echo $SHELL
Ensure it outputs /bin/zsh or the path to your zsh shell.
If it doesn’t, you may need to manually set the terminal profile. Go to the Command Palette (Cmd + Shift + P) and select Terminal: Select Default Profile. Choose zsh from the list.
- Verify the Fix
Open a new terminal in VS Code.
Run:
nvm -v pnpm -v brew -v
These commands should now work without the command not found error.
If the problem persists, ensure your VS Code is fully updated, and check for any conflicting extensions or settings that might override terminal behavior. Let me know if you need further assistance!
Good Luck :)
本文标签: macosVS Code not finding any installed packages in terminal on mac installationStack Overflow
版权声明:本文标题:macos - VS Code not finding any installed packages in terminal on mac installation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301215a1931102.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论