Register Login

'ng' is not recognized as an internal or external command

Updated Jul 25, 2023

If you are a web developer trying to use the Angular CLI for creating a new Angular project or run various Angular commands but facing the error "ng is not Recognized as Internal or External Command, Operable Program or Batch File?", then this the right article for you.

Tackling this error and fixing it with the right solution is often challenging and can prevent users from being able to operate the Angular CLI as required. Let us dig deeper into this topic and find a solution to fix this problem. The article will highlight two solutions as alternatives to confirm fixing the error.

What is ng in Angular?

These are model directives used for two-way data binding in AngularJS. Angular offers an ng-app that allows users to work with Angular applications. They can use this ng-model for Angular app views, like text fields.

On the other hand, they can use the ng-init for initializing data and variables. For extending the HTML, users use the AngularJS directives. These directives bind the value of HTML controls, such as input, select, and textarea, to application data.

But while working with the ng directives, encountering the error "ng is not recognized as Internal or External Command, Operable Program or Batch File?" is common. It often occurs when users do not install the Angular command line tool on their system.

Or they do not add the ng Path variable added in Windows. This article will review these problems and solve the error.

Fixing the error: "ng is not recognized as an internal or external command in angular"

Before jumping into the solution section, users first install the NPM or Node Package Manager as a prerequisite. It is a popular and the world's largest software registry for Node.js. Then, we proceed to the solutions to the error and fix it successfully:

Solution 1: Adding the path of the ng to the window

One of the causes of encountering the error is the ng path not set in Windows. Users must first add the ng to the Windows path and then access it in the command line. Follow the steps for adding the path:

Step 1: Find and use the ng and the "ng.exe" file. Find the location where the ng got installed or where the file exists. Use the "where" command to accomplish this:

where ng

Choose and copy the path where ng got installed.

Step 2: Launching the environment variable settings

Go to the Start menu for setting the ng path pt the Windows. Click on the "Environment Variables" option from the Advance Setting panel.

Step 3: Go to the path property under the "System variables" box. Click on the Edit option.

It will direct the users to the "Edit environment variables" window, where they should click New. Then, they put the copied path where ng got installed. Press Ok.

Step 4: Check whether the solution has fixed the error by verifying it. Check the ng version by the following command:

ng version

Solution 2: Another feasible solution for fixing the error "ng is not recognized as an internal or an external command" is as follows:

Install the Angular Command Line Tool

Users use the command line tool for creating and maintaining initialized Angular applications. These are also called the Angular/CLI tool. But the error may arise when users do not install the Angular command line tool on their system. Type the command and > ng version and see whether the error occurs.

Step 1: Go to the Start menu, and open Command Prompt.

Step 2: Now users need to install Angular CLI Tool. They can use the NPM, which includes thousands of packages to install the Angular command line tool. Write the following command and run it:

npm install -g @angular/CLI

Step 3: Check whether the solution has fixed the error by verifying it. Check the ng version by the following command:

ng version

Conclusion

Users must find the correct solution for fixing the error "ng is not Recognized as an Internal or an External Command" while working with AngularJS. This error occurs for some specific reasons, not adding the ng oath to the environment variables or not installing the Angular CLI Tool. The article explicitly cited solutions according to the error problems so users to get on the right track.


×