why I have this error bash ng command not found while I already installed the angular-cli

my problem is that after installing angular CLI and started working with angular something happened and the ng command became not found command:

ng serve -o

please check this picture: bash: ng: command not found

but when I write it with the npx command it works:

npx ng serve -o

does anyone knows why?

Answer

Are you sure that Angular is globally installed in your machine? If no; try this :

npm install -g @angular/cli

if yes; the problem can be due to the reason that npm is unable to find ng command, you can try linking the angular/cli to npm like this :

npm link @angular/cli