sunny bisht
sunny bisht

Reputation: 761

ANGULAR - Error: You need to specify a command before moving on. Use '--help' to view the available commands

I am facing the issue ,

Error: You need to specify a command before moving on. Use '--help' to view the available commands

everytime while using any of the ng command

Upvotes: 63

Views: 131008

Answers (14)

Adeel Ahmed
Adeel Ahmed

Reputation: 345

Angular 17:

Try to install latest version, this is recommended approach

npm install -g @angular/cli

Ensure the Angular CLI is installed globally

ng --version

You can use following command to see a list of available commands

ng help

Note: Please also make sure that you have installed compatible version of Node.

I hope this would be helpful to resolve the issue.

Upvotes: 0

Abdullah
Abdullah

Reputation: 2973

ng v

After upgrading to the new version I am facing an error with ng --version cmd, but I am able to see the angular version with ng v

enter image description here

Upvotes: 16

François
François

Reputation: 27

I had the same problem and the uninstall/install angular cli didn't solve it.

What worked for me : There was a path to C:\Users*username*\AppData\Roaming\npm\ and another one to C:\Users*username*\AppData\Roaming\npm\node_modules@angular\cli

I removed the second path and restarted my CMD console

It worked again.

Upvotes: 1

João Renault
João Renault

Reputation: 43

Shell incompatibility in Windows

For me I discovered it was a Shell incompatibility. The only one that recognize ng commands is PowerShell.

These below show the same error:

  • CMDER
  • GitBash
  • CMD

Hopefully this will be fixed in the future.

Upvotes: 4

Dhrumil Sangani
Dhrumil Sangani

Reputation: 41

It is showing error beacuse you are run your command in command prompt and ng --version is used to run on git bash, so either you have to use git bash to run ng --version command or you need to just write ng v on command prompt.

Upvotes: 4

user19337016
user19337016

Reputation: 91

for window 10 use ng v command only, and also check environment variable.

Upvotes: 9

Asam
Asam

Reputation: 109

Uninstalling and Installing @angular/cli did not work for me this answer fixed it

make sure you have proper path variable configured as shown below Go to your system variable settings path variable snapshot make sure you have all these mentioned as part of path C:\Users\AppData\Roaming\npm\node_modules@angular\cli C:\Users\AppData\Roaming\npm C:\Program Files\nodejs

https://stackoverflow.com/a/71602204/6314006

Make sure to edit the path under System variables.

Upvotes: 0

Janaki Manathunga
Janaki Manathunga

Reputation: 111

ng --version

Error: You need to specify a command before moving on. Use '--help' to view the available commands.

  1. Check your node version.
node --version v16.16.0 (new version)
  1. type
ng v

Upvotes: 11

NeNaD
NeNaD

Reputation: 20354

Try it with Power Shell

Usually, the default terminal is Command Prompt.

Change that to Power Shell and try it again. For some reason, Command Prompt can not execute Angular CLI commands, at least in my end.


In you are using VS Code, you can check here how to change default terminal.

Upvotes: 6

pratyushranjan bohidar
pratyushranjan bohidar

Reputation: 491

I was also facing the same issue while running the ng --version. I tried to uninstall and reinstall but it didn't work. With cli 14, ng --version doesn't work.

So use ng version instead.

Upvotes: 49

sovanmahapatro
sovanmahapatro

Reputation: 31

try running command prompt as Admin and then run- npm install -g @angular/cli

Upvotes: 0

rohit.khurmi095
rohit.khurmi095

Reputation: 2661

Uninstall Angular old version & Install latest version (14)

npm uninstall -g @angular/cli 
npm install -g @angular/cli

Use:

ng version | ng v 

Instead of:

ng -v | ng --version

Upvotes: 137

WhiteShadow
WhiteShadow

Reputation: 451

I actually upgraded ng version just a day ago. I faced same problem. This happened because the current version in your system got depreciated ( no longer in use). So you have to update ng version in your system.

npm uninstall -g @angular/cli
npm install -g @angular/cli

this will help to update your angular version in your system and to check, you have to give ng version instead ng --version.

I hope this is helpful.

Upvotes: 33

Artsiom Krukouski
Artsiom Krukouski

Reputation: 57

You just need to specify the command. Try to put 'ng version', but before that, you should make sure that you have Angular CLI

Upvotes: 2

Related Questions