Windows OS

How to Fix “ng is not Recognized as Internal or External Command, Operable Program or Batch File?”

The Angular JS structural framework provides new directives (classes that control and manipulate elements) for HTML. HTML is extended by AngularJS directives are attributes with the prefix ng-. Angular provides ng-app used for angular applications, ng-model is used for Angular app views such as text fields, and ng-init is used to initialize data and variables.

Sometimes during using the ng directive on Command Prompt, we encounter the error “ng is not Recognized as Internal or External Command”. It may occur if the angular command line tool is not installed on the system, or the ng Path variable is not added in Windows.

In this blog, we will compile the following solutions to resolve the specified issue.

So, let us get started!

Prerequisites: Install NPM

Npm is a well-known package manager that supports JavaScript applications. NPM will be set up right away after Node.js is installed on Windows. Here is the URL for the article explaining how to use NPM to install Node.js:

To discover how to install NPM on Windows, visit the “How to install Nodejs on Windows” page.

Solution 1: Install Angular Command Line Tool

The command line tool that is primarily used to create and maintain initialized Angular applications is known as the Angular/CLI tool. The specified error may occur if the Angular command line tool is not installed on the system.

As you can see, when we try to check ng which is a prefix of Angular it shows an error.

> ng version

We can resolve the “ng is not Recognized as Internal or External Command” error by installing “Angular/cli” on Windows which can be easily installed using the NPM package manager. To fix the specified error, follow up on the listed procedure.

Step 1: Open Command Prompt

First, open the Windows Command Prompt by searching it in the Start menu:

Step 2: Install Angular CLI Tool

Utilize NPM which contains thousands of packages to install the Angular command line tool. For this purpose, execute the mentioned command:

> npm install -g @angular/cli

Step 3: Verify if the Problem is Resolved or Not

Let’s verify whether the error is fixed or not. To do so check the ng version on Windows:

> ng version

Solution 2: Add Path of ng to Windows

The error “ng is not Recognized as an Internal or an External Command” may occur if the ng path is not set in Windows. Before accessing ng from the Windows command line, ng must first be added to the Windows path. In order to accomplish this and to resolve the found error, use the following instructions.

Step 1: Find ng Installation Location

To find out where the ng is installed or where the “ng.exe” file exists, utilize the “where” command as shown below:

> where ng

After determining the location of the ng installation, choose and copy the Path where ng is installed:

Step 2: Launch Environment Variable Settings

Open the environment variables setting by searching it in the “Startup” menu to set ng path to Windows path:

Hit “Environment Variables” button from the Advance Setting panel:

Step 3: Set ng Path to System Variable

After that, select the “Path” property under “System variables” and then click the “Edit” button:

Next, in the “Edit environment variables” window, click “New” and put the copied path of ng installation location here, and then click “Ok“:

Step 4: Verify if the Error is Resolved or Not

Let’s check if the error has been resolved or not. To do this, again check the ng version here:

> ng version

You can see that we have successfully fixed the specified error on Windows:

We have provided feasible solutions to fix the “ng is not recognized as an internal or an external command” error.

Conclusion

You could run into the problem “ng is not Recognized as an Internal or an External Command” for a variety of reasons. It’s possible that the ng installation path was not added to the Path environment variable or that the angular command line tool was not installed. The first solution is to install angular/cli using NPM and the other is adding the ng path to Windows advance settings. In this blog, we have compiled feasible solutions to resolve the specified error on Windows.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.