Samir Acharya
Samir Acharya

Reputation: 33

zsh: command not found: ng

I have setup my angular project in bash terminal(default one). Command like

ng s

It worked fine.

Now I change my default terminal to zsh. On running command

ng serve 

throws error:

zsh: command not found: ng

It work fine if I switch my new default-terminal(zsh) to bash; again to zsh. I think zsh does not understand the packages installed in bash initially

How to fix this command not found issue?

Upvotes: 3

Views: 12690

Answers (4)

Arunkumar R
Arunkumar R

Reputation: 21

If your node version is 22, try dropping to 20; it worked for me. Node versions higher than 20 will also throw this.

Upvotes: 0

Lorraine Ram-El
Lorraine Ram-El

Reputation: 2745

Move command source <(ng completion script) from ~/.zshrc file to the end of ~/.zprofile file.

This way, the ng command would be referenced correctly after zsh startup scripts load. @starterProgrammer answer is not correct as it deletes the command and doesn't solve the problem. Also, no need to reinstall the angular CLI if it is already installed.

Upvotes: -1

Bego CM
Bego CM

Reputation: 31

To solve the error "ng: command not found", install the angular cli package globally by npm install -g @angular/cli@latest and restart your terminal.

If the global installation of Angular fails, you might have to run the command prefixed with sudo.

get package version ng version.

Upvotes: 2

greghvk
greghvk

Reputation: 86

Possibly, on startup bash adds ng location to PATH, but zsh doesn't. You can check ~/.bashrc and ~/.bashprofile to see what is added to the PATH variable (all lines starting with export...), and copy these lines to ~/.zshrc file.

Upvotes: 2

Related Questions