Search code examples
cmdangular-cli

How to run `ng` in windows


I have installed Angular-cli locally. The path is .../node_modules\@angular\cli\bin. I see that there is an ng file at this path.

23/05/2018  09:03    <DIR>          .
23/05/2018  09:03    <DIR>          ..
23/05/2018  09:03             6,627 ng

I want to check the version of angular-cli but when I run .\ng --version in windows cmd, I get the error ng is not a recognised command.

How can I find ng's version using cmd?


Solution

  • If you have installed ng-cli in the developer dependencies of the project, you cannot use it directly from the command line.

    You have two options to use this:

    1. Install it globally using -g
    2. Use npx

      npx ng
      

    You can use npx from the project root to use the one that is included in project dependencies. npx will resort to downloading ng and running the rest of the command without polluting global namespace.