Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I open the terminal shows "The specified command("completion") is invalid. For a list of available options, run "ng help"

When I open the terminal did't do anything. It will shows errors as below.

enter image description here

like image 675
Eve-Sama Avatar asked Aug 31 '25 15:08

Eve-Sama


2 Answers

I had the same error after updating angular every time after opening the terminal.

Depending on which terminal you use either open configuration file which will be saved in ~/.bashrc, or for zshell ~/.zshrc, and so on for others,

Edit the corresponding ~/.bashrc or ~/.zshrc file and delete or comment this line:

source <(ng completion script)

Sadly you will lose the angular autocompletion, but it looks like there is some bug causing this in their implementation

like image 88
Etaos Avatar answered Sep 02 '25 10:09

Etaos


According to angular.io, ng completion will help you in command line mode. So, if you face the problem, you can try to fix it rather than simply remove it. This command works in Angular 14.

First you should try to upgrade your @angular/cli by below commands:

npm uninstall @angular/cli
npm i --location=global @angular/cli

After this, you should try to open a new terminal, see if the problem still exists.

If yes, then probably you used a wrong ng, by running command which ng, it will tell you the "global" ng location. Almost 100 percent it is not the one you have just installed.

So you can just delete this ng and it's related node_modules/@angular, then re-install angular cli.

It should work now.

like image 40
Bryan Yin Avatar answered Sep 02 '25 10:09

Bryan Yin