[windows-7] ng is not recognized as an internal or external command

Running windows 7 Professional 32bit.

I tried running npm install -g angular-cli both under normal or admin. 2016-06-23_14h46_40

I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also.
2016-06-23_14h56_48

What am i doing wrong?

This question is related to windows-7 angular angular-cli

The answer is


In my case I did below steps.

All Programs -> Node JS-> Right click on Node.js Command Prompt and select properties and from Target string at end copy below

/k "C:\Program Files\nodejs\nodevars.bat"

I launched Visual Studio Code and opened below file

C:\Users\gochinta\AppData\Roaming\Code\User\settings.json and gave below

// Place your settings in this file to overwrite the default settings
{
  "terminal.integrated.shellArgs.windows": 
  ["/k", "C:\\Program Files\\nodejs\\nodevars.bat"]

}

Now I typed ng -v in my Visual Studio Code Terminal window and it worked.


execute following lines in order to solve the issue for both not found and undefined version of ng

npm uninstall -g angular-cli

npm uninstall --save-dev angular-cli

npm cache clean

npm install -g @angular/cli@latest


I had the same issue of Visual Studio Code not being able to run any ng commands in it's built in terminal.

I added %AppData%\npm to the path in Windows 10, and did not have to reboot, just closed and reopened VS Code and not it sees it.


Navigate the directory where you want to create the application and run the command:

PATH="Path where your node is installed";%PATH%


I followed below steps for resolution for this issue in Windows 10:

  1. First make sure you have installed Angular CLI . You can use below to install same.

npm install -g @angular/cli@latest

  1. Make sure that AppData is visible and navigate to path below.

C:\Users\rkota\AppData\Roaming\npm

Same path can be found by running below too:

npm config get prefix

  1. Add the above path i.e. " C:\Users\rkota\AppData\Roaming\npm" in Environment variable PATH and make sure it got added by running path in command prompt.
  2. Close command prompt and now try to run below:

ng --version

you will be able to see CLI version.


Add the ng command path from the folder .bin under the node_modules to PATH variable in the system env settings.

e.g: add C:\testProject\node_modules\.bin\ to PATH

Restart your IDE.


close cmd and open it again with admin right or reboot ur system.


In my case, even though %appdata%\npm was already in PATH, I had to delete and add it again in the system variable editor. Restarting OS / reinstalling Angular CLI did not help for some reason.


I resolved by adding - %AppData%\npm\node_modules@angular\cli\bin\ path to my environment variables path


With a command

npm install -g @angular/cli@latest

It works fine, I am able to run ng command now.


I am using WIN 10, just figure it out for this problem. Type the code below in cmd:

npm config get prefix

and copy&paste the path that you get it from the top into your computer environment variables-->user variables box --> path --> edit -- C:\Program Files\nodejs\node_global, your path may different.

Click Ok and reopen your cmd window, type in ng version, then it works! Cheers!


I don't have a global Angular install, only project level. One of my projects kept throwing this error while others with same setup worked fine! I just

  1. Removed the node_modules folder from the project
  2. Ran npm i in the project

Works fine now.


I faced same issue on x86, windows 7;

  • uninstalled @angular/cli
  • re-installed @angular/cli
  • checked & verified environmental variables (no problems there)...
  • Still same issue:

Solution was the .npmrc file at C:\Users{USERNAME}... change the prefix so that it reads "prefix=${APPDATA}\npm"... Thanks to this website for help in resolving it


This one almost worked for me, but I had to use: %USERPROFILE%\AppData\Roaming\npm . In Environment Variables.../System variables/Path

Then when I did CMD: "ng -v" I got the correct response for angular cli.


Use Node.js command prompt and execute the command

ng version

It should work.


If you're looking to actually find where ng is located you can then type where ng and it will show you which ng is running (eg. C:\Users\USERNAME\AppData\Roaming\npm). You can then look at your path and see if adding that folder is helpful. The Node.js command prompt adds extra paths that may be missing from your path.


I was having the same issue when tried with the syntax "ng new " and solved that simply by updating the existing node version from 5.x.x to 8.x.x. After successful updation of node, the syntax worked perfectly for me. Please update the existing version of node. As it is clearly mentioned in angular documentation that these commands require the node version >= 6.9.x. For reference please check https://angular.io/guide/quickstart. It clearly states "Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine".


I had to add the npm path to the user PATH environment variable as well. You can do that by running the following PowerShell script as admin:

$path = npm config get prefix    
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")

if (($userPath -split ';') -notcontains $path) 
{
    [Environment]::SetEnvironmentVariable("PATH", ('{0};{1}' -f $userPath, $path), "User")
}

try to set system variable path with %AppData%\npm\. and make sure visibility of AppData folder. this folder should be visible (not hidden).


If you get the error even after following the above step. then try below.

Since it is a node script. I am using the below option to create as of now.

node C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng version

May be symbolic links are required. Not researched further.

On Further Research: Set Path as : %PATH%;C:\Users\Administrator\AppData\Roaming\npm;

In Windows, npm.cmd file is in the above path. If the above Environment variable is set, you can execute as ng version ng init


Instead of using the in-built command prompt better start using the NodeJS installed version of command prompt. Then it is going to work perfectly without any issues.enter image description here


I faced same issue when i tried to install angular cli locally with command

npm install @angular/cli@latest

After that i got same issue C:\Users\vi1kumar\Desktop\tus\ANGULAR\AngularForms>ng -v 'ng' is not recognized as an internal or external command, operable program or batch file

Than i tried to install it globally

npm install -g @angular/cli@latest

In this case case it worked i was wondering that is it not possible to install cli globally ?

After doing some research i found this article very helpful hope it will help someone facing similar issue

Working with multiple versions of Angular CLI


I was also following this problem so I tried this command and it worked perfectly. Use this command: npm run ng


Set path=%path%;C:\Users\\AppData\Roaming\npm


I had the same problem on Windows 7, 64 bits running with npm v3.10.8.

  1. I added the path as it was suggested: ( C:\Users.....(your user name)\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) and uninstalled angular-cli.
  2. After this, I cleared the npm cache by npm cache clean as prompted here https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/. This guarantees there are no leftovers.
  3. Reinstalled angular-cli with npm install -g angular-cliand voila.

    Hope that may be useful!

For me something was wrong in the PATH enviroment variable. I removed all path related to npm and added at the start of PATH this folder:

c:\Users\<your-user-name>\AppData\Roaming\npm\

Make sure you have ; between paths.


Adding C:\Users\DELL\AppData\Roaming\npm to System Variable Path worked for me. Please find your appropriate file path to 'npm'

Also, check if you have added your angular-cli\bin path to the path variable.


  1. Open cmd and type npm install -g @angular/cli

  2. In environment variables, add either in the user variable or System variable "Path" value=C:\Users\your-user\.npm-packages\node_modules\.bin

  3. In cmd: c:\>cd your-new-project-path

  4. ...\project-path\> ng new my-app

    or ng all-ng-commands


Sometime in the future. Applicable to Windows 8.1 machine. Run the following commands

npm install -g @angular/cli

Log out or restart your machine.

This should add the required env path, rather than doing it manually.


Before try to update the PATH varibles on Windows 7 (x64), run CMD console AS ADMINISTRATOR and ng command works for me, this also applied to VISUAL STUDIO CODE Console.

It worked for me on both CMD CONSOLE / VS CODE


Set the new path to C:\Users\yourname\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng It works fine now for me


I am facing same issue and it's get resolved. At my end reason is i install node and CLI using other user profile and now i am running ng command from other user login. Since node and cli installed using other user login node is not finding anything on C:\Users\&lt;user name&gt;\AppData\Roaming this path and that's why i am getting this error.

I run npm install -g @angular/cli command and restart my machine. Every thing is working fine.


Had the same problem on Windows 10. The user's %Path% environment already had the required "C:\Users\ user \AppData\Roaming\npm".

path command would not show it, but it did show tons of other paths added earlier by other installations.

Turned out I needed to delete some of them from the system's PATH environment variable.

As far as I understand this happens because there's a length limit on these variables: https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable

Probably happens often on dev machines who install lots of stuff that needs to be in the PATH.


For me it works with:

npm run ng <command>

1) Enter below command on command prompt

npm install -g @angular/cli

2) Make sure that C:\Users\_username_\AppData\Roaming\npm this path is not hidden.

3) Add C:\Users\_username_\AppData\Roaming\npm and

C:\Users\_username_\AppData\Roaming\npm \node_modules@angular\cli\bin to both enviroment variable path.

4) Open new command prompt and type ng help. It will work.


npm install -g @angular/cli helped for me instead of npm install @angular/cli


Since this question is still asked over and over again one year later I will post my answer here as well.

The clue (on Windows only) is to arrange the entries in the path variable right.

As the NPM wiki tells us:

Because the installer puts C:\Program Files (x86)\nodejs before C:\Users\\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm@<version>.

So your path variable will look something like:

…;C:\<path-to-node-installation>;%appdata%\npm;…

Now you have two possibilities:

  1. Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…

This will load the npm version installed with npm (and not with node) and with the installed Angular CLI version.

  1. If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this: …;C:\Users\<username>\AppData\Roaming\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;… or …;%appdata%\npm\node_modules\@angular\cli;C:\<path-to-node-installation>;%appdata%\npm;… for the short form.

This worked for me since a while now.


I solved this problem in accordance with the figure:

run in cmd

 npm install -g @angular/cli

and then

( open in Windows 10) Control Panel\All Control Panel Items\System or accordance with the figure

step 1:

enter image description here

step 2 :

enter image description here

step3:

enter image description here

step4:

enter image description here

step5: add missing ng path

enter image description here

Finally, restart all opened command prompts, or you can also restart the computer.


PATH environment variable should be updated by adding following path,

C:\Users\xyzname\AppData\Roaming\npm\node_modules\@angular\cli\bin

Because ng file is in bin folder, once this is added for sure ng will be recognized


I had the same problem today and have gone through the following path - (%USERPROFILE%\AppData\Roaming\npm) and came to know that there is some junk data and when I cleared everything under npm directory. Now when I ran (npm install command again). Now everything works fine.


Just open your command prompt (run as administrator). Ensure node --v is 6.9.0 or higher and npm --v is 3.0.0 r higher.

After that run the following command:

npm install -g @angular/cli

Once angular is installed. you can see an entry of angular cli in the path

C:\Users\Dell\AppData\Roaming\npm\node_modules\@angular

Then try ng help. It will work.


I had the same problem and solved it completely by running VS Code as Administrator.

I used the above mentioned solutions (npm install -g @angular/cli@latest & npm install @angular/cli in my project), tried ng serve both in cmd and VS Code terminal but didn't work, while npm run ng serve could run in VS Code terminal, but I wasn't satisfied with that. After that I set the path in the environment variables exactly like this "C:\Users\TheUserName\AppData\Roaming\npm" and still wasn't able to run ng serve.

Then I ran VS Code as Administrator and it finally worked. It even recognized another command, gulp, which didn't recognize till then, even though I had it also correctly installed. Not sure why it had this behavior and I would like an explanation.


After installation: Go to start Menu Type Environment variable click on "edit the system environment variables", It will open a window In window, click on "Environment variable" button Double click on "Path" then click on new and add the below environment variable C:\Users\\AppData\Roaming\npm (or open run window type %AppData% and open npm folder there. Provide this location in environment variable.)


I also tried to play with cmd by setting environment variable path & etc, but simple answer is use nodejs command prompt.

So you no need to set environment variable path or anything. When you insalled nodejs it will give it's command prompt, by using that you us "ng" command, without any settings.


1- Install

$ npm install -g @angular/cli

2- Make sure where your ng.cmd is present.

enter image description here

3- Then add this path into variables.

enter image description here


You can check in this way. I had the same problem. First, check your user PATH in the environment variable.That must point to "%USERPROFILE%\AppData\Roaming\npm\node_modules\@angular\cli\

Instead of command prompt use the node.js command prompt. Run node.js command prompt from installed program menu. Go to start and search for node.js command prompt. Run it then type ng -v hit enter. It will work. Let me know your if it helps or not.


Install x32 version nodejs instead of x64 version (even on 64-bit windows machine).


Examples related to windows-7

ng is not recognized as an internal or external command Why am I getting ImportError: No module named pip ' right after installing pip? How to Delete node_modules - Deep Nested Folder in Windows Telnet is not recognized as internal or external command Multiple -and -or in PowerShell Where-Object statement How do I set ANDROID_SDK_HOME environment variable? Run Batch File On Start-up Why isn't .ico file defined when setting window's icon? How to access shared folder without giving username and password Can't start hostednetwork

Examples related to angular

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class error TS1086: An accessor cannot be declared in an ambient context in Angular 9 TS1086: An accessor cannot be declared in ambient context @angular/material/index.d.ts' is not a module Why powershell does not run Angular commands? error: This is probably not a problem with npm. There is likely additional logging output above Angular @ViewChild() error: Expected 2 arguments, but got 1 Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' Access blocked by CORS policy: Response to preflight request doesn't pass access control check origin 'http://localhost:4200' has been blocked by CORS policy in Angular7

Examples related to angular-cli

Why powershell does not run Angular commands? ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found Could not find module "@angular-devkit/build-angular" How to remove package using Angular CLI? How to set environment via `ng serve` in Angular 6 Error: Local workspace file ('angular.json') could not be found How do I deal with installing peer dependencies in Angular CLI? How to iterate using ngFor loop Map containing key as string and values as map iteration how to format date in Component of angular 5