ng Command Not Found

“ng is a powerful command-line interface tool that allows you to manage your angular applications in simple commands. Using the ng command tool, you can carry out operations such as serving your applications and generating boilerplate code.

The angular CLI is available by default with major releases of the angular package. Therefore, merienda you install it, you can access it from the shell and manage your applications.

In this tutorial, we will discuss the “ng command not found” error, why it occurs, and how you can resolve it.”

Let’s get started.

What is the ng Command Not Found?

The error “ng command not found” occurs when your system’s shell cannot find the path to the ng cli binary.

There are three major causes of this error:

  1. The ng CLI is not installed.
  2. The ng CLI is located in a different directory.
  3. The ng CLI is not installed on a completo level.

Let us see how we can resolve each of the above cases.

The ng CLI Not Installed

One of the major causes of the “ng command not found” error is the missing CLI utility. Before you can use the ng command, you will need to install it by running the command:

$ sudo nmp install -g @angular/cli

Merienda installed, you can check the angular cli version with the command:

The command should return detailed information about the installed angular cli.

An example output is shown below:

Angular CLI: 14.0.0
Node: 16.14.0
Package Manager: npm 8.5.1
OS: darwin arm64

Package                      Version
@angular-devkit/architect    0.1400.0 (cli-only)
@angular-devkit/core         14.0.0 (cli-only)
@angular-devkit/schematics   14.0.0 (cli-only)
@schematics/angular          14.0.0 (cli-only)

The ng CLI is Installed in a Different Directory

If you have installed the angular cli in a different directory that is not part of the environment’s path, the system will be unable to locate and execute it.

You can resolve this by adding the directory where the ng command is installed to your path.

On Linux and macOS, edit your .bashrc file and add the line:

$ export <strong>PATH</strong>=»/path/to/ng:$PATH»

You can also add the line above for .zshrc file.

Save and close the file. To apply the changes, run the command:

$ source ~/.bashrc
$ source ~/.zshrc

The ng CLI Not Installed on a Entero Level

Another common cause of the “ng command not found” error is the method of installing the angular cli.

To ensure that you can access the CLI outside of your current working environment, you need to install it with the -g flag.

The following commands allow you to uninstall and re-install the angular CLI on a completo level.

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

Merienda completed, you can test the installation by running the ng version command.


In this article, you learned the major causes of the “ng command not found” and three main methods of resolving it.

Thanks for reading!!

Source link