7

I try to install Angular but after installing i got this error

ng is not recognized as an internal or external command,operable file or batch file

I installed node,npm and git I gived below comment for installing Angular.I installed after installing i give ng-v comment i found this error.

npm install -g @angular/cli

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Raghul Rajendran
  • 486
  • 2
  • 7
  • 25

8 Answers8

6

Add your node js path ex: " C:\Users\DELL\AppData\Roaming\npm" to System Variable source :follow this link

Sathish Kotha
  • 1,081
  • 3
  • 17
  • 30
3

Execute below command:-

npm uninstall -g angular-cli

npm uninstall --save-dev angular-cli

npm cache clean

npm install -g @angular/cli@latest

Try out it for me it worked

1

Open a new terminal and try again. Sometimes after installing the package, this error message appears if you use the same window.

If not add it to environment variables.

Ajantha Bandara
  • 1,473
  • 15
  • 36
1

I personally never install angular-cli globally. What I do is -

  1. Create a .bin folder some where in your workspace
  2. Use npm npm install @angular/cli
  3. Come back to your root of workspace
  4. Create an angular app using - .\path to .bin\node_modules\.bin\ng new new-app

And you will be good to go.

Abhishek Prakash
  • 964
  • 2
  • 10
  • 24
1

Spent days on this. Had 2 different machines and one worked like a charm the other I ended up uninstalling VS2017, NodeJs to start clean. I would install Nodejs without VS installed. Reinstall NodeJS then angular/cli and no NG recognized using NodeJS command prompt or any other command prompt. On NPM get it said it was installed in path "c:\ProgramData\Microsoft\VisualStudio\MDA..taco-toolset.." which made no sense since VS was completely gone.
The solution: In c:\Users\YouUserName.nmprc file persisted after uninstalling Nodejs. Delete this file and reinstalled NodeJS then Angular/cli and all was good.

I think this maybe a result of installing VS2017 with node project types. Not sure but it was one big mess which google lead to no solutions.

RandallTo
  • 395
  • 2
  • 11
1

Add Following path

Just add path to global npm location:

C:\Users\username\AppData\Roaming\npm

The above directory contains "ng" command enter image description here

Pramod Mali
  • 1,588
  • 1
  • 17
  • 29
0

Try to run with sudo.
install your node and npm globally

alytvynov
  • 81
  • 12
0

In my case, I was using VSCode and WSL.

I was trying to generate a service from VSCode's Angular Schematics and got the same issue.

Meanwhile, the path "./node_modules/.bin/ng" was actually there since the beginning while generating the project from angular cli. It's also included on the devDependencies section in package.json after generating an angular project.

However, it seems that it needs sudo or special permission to invoke the ng command from that particular directory. While, there's no way we can override the command from VSCode.

On the other hand, I also had @angular/cli installed globally.

Uninstalling the project's (local) @angular/cli should do the trick, by using this command:

npm uninstall -D @angular/cli

Therefore, VSCode's angular schematics (or any command that needs it) will try to use the global @angular/cli that you've installed beforehand.

In case you haven't install it, then install it using:

npm install -g @angular/cli.

That should do the trick.

MazBeye
  • 666
  • 7
  • 12