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?

6 Answers 6

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"
    }
  },
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.

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! Jan 3, 2021 at 1: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. Jan 4, 2021 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. Mar 9, 2021 at 22:35
  • 1
    This is now deprecated. New recommended way is "terminal.integrated.defaultProfile.osx": "zsh" Jul 22, 2021 at 8: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"
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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.