2

For some reason, yesterday, all my commands (ng, npm, node, etc.) were working fine, but at night I cleaned my PC from trash files and all that (my pc has Windows installed), and now it doesn't recognize the ng command, but all the others are OK.

I checked the Environment Variables and its path is there, I checked the path, and it's all right, I re-installed with:

npm install -g angular-cli**

However, nothing happened. I rebooted the computer and all that, but I just can't get ng working again.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Erick Rosas
  • 141
  • 3
  • 14

3 Answers3

1

I ran into this same snafu when I was trying to install Angular (v4.0) correctly. The way I corrected it, after I incorrectly executed npm install @angular/cli -- which generated a directory called node_modules.

To correctly install angular with npm, remove the directory node_modules, then simply start a new bash shell or simply open a new console or terminal tab, and execute sudo npm install -g @angular/cli. This may prompt you for your machine's password, so be prepared to enter it without being able to see it.

It seems like you were following the Angular weblog's instructions for installing Angular v4. You can do that instead instead just as easily; The key to installing Angular v4 correctly on my machine (besides updating my nodejs installation to the prerequisite latest version), was using sudo with the -g (aka. global) option.

Levi Maes
  • 124
  • 2
0

At the end I made it work, I had to uninstall even all my NodeJs, de @angular/cli and the angular-cli, Rebooted my computer and then reinstalling NodeJs latest version and installed Angular with npm install -g @angular/cli@latest and removed from PATH and Environment Variables the old paths and got it running fine!

Erick Rosas
  • 141
  • 3
  • 14
0

For me (In Windows) the problem was that the npm path was not saved in the path environment variable. If you browse to

C:\users\yourname\AppData\Roaming\npm

Inside this directory you can see ng (a javascript file) and ng.cmd (the windows command file that executes the javascript file). This path needs to be in your path variable to be able to call ng

jazza1000
  • 4,099
  • 3
  • 44
  • 65