7

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://stackoverflow.com/a/58584109/6647188 but it uses third party tools which I'd like to avoid if possible. Is there no other known way to resolve this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kyle Vassella
  • 2,296
  • 10
  • 32
  • 62

6 Answers6

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"
    }
  },
Norfeldt
  • 8,272
  • 23
  • 96
  • 152
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.

Amol
  • 1,084
  • 10
  • 20
Victor Martinez Calvo
  • 1,717
  • 1
  • 12
  • 11
  • 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! – Kyle Vassella Jan 03 '21 at 01:11
  • @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. – user1934428 Jan 04 '21 at 13:48
  • @user1934428 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. – Kyle Vassella Mar 09 '21 at 22:35
  • 1
    This is now deprecated. New recommended way is `"terminal.integrated.defaultProfile.osx": "zsh"` – Kieran Crown Jul 22 '21 at 08:01
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"
Tectumor N
  • 21
  • 2
0

try this. worked for me

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

https://stackoverflow.com/a/48415572

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.

ariel guzman
  • 590
  • 7
  • 11
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.
Mostav
  • 2,203
  • 15
  • 27