Fixed- "error: you need to specify a command before moving on. use '--help' to view the available commands."


To resolve the error "error: you need to specify a command before moving on. use '--help' to view the available commands.":

Make sure to specify a valid command when using the command-line interface. If you're unsure of the available commands, you can use --help to view the available options.


To resolve the error "error: you need to specify a command before moving on. use '--help' to view the available commands.":

Make sure to specify a valid command when using the command-line interface. If you're unsure of the available commands, you can use --help to view the available options.

Use ng version instead of ng --version because the hyphen throws an error with different node versions.

I discovered that my Angular CLI was referencing one of these paths:

  • C:\Users[myuser]\AppData\Roaming\npm\node_modules@angular\cli\bin\ng.js
  • C:\Users[myuser]\AppData\Roaming\npm\ng
  • C:\Users[myuser]\AppData\Roaming\npm\ng.cmd

When I executed Angular from .\@angular\cli\bin, the problem occurred exactly as described.

However, when I executed it from .\npm\ng, it worked fine.

Therefore, the solution was to edit the system path to remove the first route and add the second one.

After making these edits, I restarted the machine to apply the changes.

I encountered the same problem, and uninstalling/installing Angular CLI didn't solve it.

What worked for me was:

  • There were two paths: one 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.

After doing this, it worked again.

If you encounter an error, it might be because you are running your command in Command Prompt, while ng --version is typically used in Git Bash. You have two options:

  • Use Git Bash to run the ng --version command.
  • Simply use ng v on the Command Prompt.

To uninstall the old version of Angular and install the latest version (14), use the following commands:

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

For checking the Angular version, use:

ng version

or

ng v

Instead of:

ng -v

or

ng --version