I am working on a school project and I had an issue with my Angular "ng" command because it was not recognized by my system.
'ng' is not recognized as an internal or external command, operable program or batch file.
However, my friend told me to run the command this way and it works magically.
I know the above path is the place where npm is installed, but I am still curious about how it works.
Which file in the npm folder runs the ng command? How come the simple ‘ng’ command does not work, but the full path command like above works? Which skills do I need to study to overcome issues like this(I would not be able to figure this out without my friend’s help)?
Most likely it doesn’t runs because you don’t have Angular CLI installed, or as a second guess, you don’t have your node install in the path variable. As a test, try running
node -v to check if that’s the case.
The real "magic" behind the bare
ng is that, when you globally install Angular CLI, it creates a
In short, the path variable together with a conveniently placed
ng.bat file plus the Windows command line convention of allowing omiting the file extension for bat files is what allows the trick of just using
Having to type the full path is an indicator that the PATH variable is missing (or set incorrectly).
npm follows the exactly same trick.
Answered By – Alejandro
Answer Checked By – Jay B. (AngularFixing Admin)