3

ng --version

Program 'ng' failed to run: No application is associated with the specified file for this operation At line:1 char:1
    + ng --version
    + ~~~~~~~~~~~~.
    At line:1 char:1
    + ng --version
    + ~~~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
        + FullyQualifiedErrorId : NativeCommandFailed

I tried to install angular by running 'npm install -g @angular/cli' command. It installed properly but when I run ng command, it shows the above error.

Amit Chigadani
  • 28,482
  • 13
  • 80
  • 98
  • Just restart your editor or terminal and try it out. Btw what command did you run? – Amit Chigadani Dec 16 '19 at 18:46
  • If Amit Chigadani's comment doesn't resolve your issue, check [this SO q/a](https://stackoverflow.com/questions/37991556/ng-is-not-recognized-as-an-internal-or-external-command) and see if something happened with your PATH env variable – Gregg L Dec 16 '19 at 18:48

3 Answers3

4

I faced a similar issue and I added the following path to my system variable path : C:\Users\AppData\Roaming\npm

Then I found ng command is working in my system command prompt but not in Visual Studio Code. Hence I followed the below steps:

  • For this click Ctrl+Shift+P and then select "Select Default Shell" option and choose Command prompt.
  • Now try running ng command in Visual Code it worked for me.
snehab
  • 684
  • 5
  • 13
1

Install node first - https://nodejs.org/en/ node -v TO CHECK NODE VERSION

Uninstall Angular

npm uninstall -g @angular/cli

npm cache clean

npm install -g @angular/cli@latest


ng -v TO CHECK CLI VERSION

Shubham Ghormade
  • 215
  • 4
  • 16
1

Sometimes this error comes if you are using powershell in VSCode terminal. I just changed it to cmd promt and it worked for me.

Vikram Sapate
  • 1,087
  • 1
  • 11
  • 16