'zsh: command not found: ng' in Visual Studio Code's integrated terminal on Mac Catalina
Asked Answered
C

6

8

Newer Macs (Catalina OS in my case) now have the default Z Shell aka zsh. Using a Mac zsh terminal window, I've successfully installed Angular 11.0.5 globally and created a project. I'm using nvm 0.32.2 and node 10.23.0.

However, on opening Visual Studio Code and navigating to my project within VS Code's integrated terminal, I get this error message using any ng command, such as trying to generate a component:

zsh: command not found: ng

Does anyone know how to properly set up Visual Studio Code's integrated terminal to properly identify ng commands using zsh?

I've found one possible work around here https://mcmap.net/q/973278/-zsh-command-not-found-ng-on-new-mac-os-catalina but it uses third party tools which I'd like to avoid if possible. Is there no other known way to resolve this?

Chabazite answered 3/1, 2021 at 0:24 Comment(0)
Z
4
  • From the menu navigate to: Settings -> Features -> Terminal

  • Click in "Edit in settings.json”

  • Add this line(key value) to the object:

    "terminal.integrated.shell.osx": "/bin/zsh"
    
  • Close and relaunch Visual Code.

Zonation answered 3/1, 2021 at 1:5 Comment(4)
I'm marking this as correct because that is what is needed. However without me doing anything, this was already present in the settings. Where I think I went wrong was that I had installed Angular globally, but had never closed and relaunched Visual Studio Code. I had opened a New Window, but this wasn't enough. A simple close and relaunch, as you stated, fixed things. Thank you!Chabazite
@VictorMartinezCalvo : Could you explain, why this is supposed to help here? Actually, the shell invoked from Visual Code by the OP is already a zsh, as we can see from the wording of the error message he gets.Basle
@Basle I should probably edit my question. The issue didn't have to do with VS Code using zshell and ng commands. The issue was (I believe) that after installing Angular globally, I needed to close and relaunch VS Code for it to recognize ng commands. @Victor Martinez Calvo did include this step in his answer, so I left this as the accepted answer.Chabazite
This is now deprecated. New recommended way is "terminal.integrated.defaultProfile.osx": "zsh"Upkeep
P
6

Here is the settings that worked for me

  "terminal.integrated.defaultProfile.osx": "zsh",
  "terminal.integrated.profiles.osx": {
    "tmux": {
      "icon": "terminal-tmux",
      "path": "tmux"
    },
    "zsh": {
      "path": "/bin/zsh"
    }
  },
Panacea answered 12/5, 2021 at 6:30 Comment(0)
Z
4
  • From the menu navigate to: Settings -> Features -> Terminal

  • Click in "Edit in settings.json”

  • Add this line(key value) to the object:

    "terminal.integrated.shell.osx": "/bin/zsh"
    
  • Close and relaunch Visual Code.

Zonation answered 3/1, 2021 at 1:5 Comment(4)
I'm marking this as correct because that is what is needed. However without me doing anything, this was already present in the settings. Where I think I went wrong was that I had installed Angular globally, but had never closed and relaunched Visual Studio Code. I had opened a New Window, but this wasn't enough. A simple close and relaunch, as you stated, fixed things. Thank you!Chabazite
@VictorMartinezCalvo : Could you explain, why this is supposed to help here? Actually, the shell invoked from Visual Code by the OP is already a zsh, as we can see from the wording of the error message he gets.Basle
@Basle I should probably edit my question. The issue didn't have to do with VS Code using zshell and ng commands. The issue was (I believe) that after installing Angular globally, I needed to close and relaunch VS Code for it to recognize ng commands. @Victor Martinez Calvo did include this step in his answer, so I left this as the accepted answer.Chabazite
This is now deprecated. New recommended way is "terminal.integrated.defaultProfile.osx": "zsh"Upkeep
F
2

If this line does not work for you:

"terminal.integrated.shell.osx": "/bin/zsh"

Then try replacing "zsh" with "bash", like so:

"terminal.integrated.shell.osx": "/bin/bash"
Famed answered 5/5, 2021 at 20:11 Comment(0)
G
0

try this. worked for me

alias ng="/Users/<user_name>/.npm-global/bin/ng"

https://stackoverflow.com/a/48415572

Gallia answered 1/9, 2021 at 2:11 Comment(0)
C
0

For the latest version of vscode at 1.62 nothing worked until I tried setting the default profile using the instructions in their docs here: https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-profiles

Not settings or commands needed just a few clicks on the IDE.

Clothespin answered 17/11, 2021 at 2:20 Comment(0)
S
0

New suggested way by vscode:

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile 
in `#terminal.integrated.profiles.osx#` and setting its profile name as the default 
in `#terminal.integrated.defaultProfile.osx#`. 

This will currently take priority over the new profiles settings but that will change in the future.
Saveloy answered 9/12, 2021 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.