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

前端 未结 19 1297
轻奢々
轻奢々 2021-01-31 01:31

I tried running npm install -g angular-cli

I also tried adding it to the Enviorment Variables under PATH: (C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node

相关标签:
19条回答
  • 2021-01-31 02:00

    I just installed angular cli and it solved my issue, simply run:

    npm install -g @angular/cli
    
    0 讨论(0)
  • 2021-01-31 02:01

    npm update solves the issue for me

    0 讨论(0)
  • 2021-01-31 02:01

    This issue also bother me and then i find possible cases to reproduce this issue

    when i run my window in administrator then it working fine ng but when i run this in my second space like other user then i got this issue.

    so if i want to run my angular application then i need to run this command

    npm run ng serve which is working but when i run the command with --host npm run ng server --host IP it not working given some error

    so i find some possible solution 1. go appdata and then user\admin\AppData\Roaming\npm folder then copy this path but if you using other user account user\newuser\AppData\Roaming\npm folder you can copy this npm folder from other user i.e admin user account. if you do not want to copy this folder then copy the path of ****user\admin\AppData\Roaming\npm folder**** folder and then open your environment variable setting and add this path in path variable name

    enter this path in system path variable not user variable C:\Users\admin\AppData\Roaming\npm

    and run the command prompt as administrator then run ng command it will work

    0 讨论(0)
  • Just adding a little info to the previous answers, If you have windows 7 or above then go to start and search Node.js command prompt and you will be directly shown the app. Click on it, and start working by using that command prompt for angular.

    0 讨论(0)
  • 2021-01-31 02:08

    I had the same issue on Windows7. I resolved it setting correct path.

    1. First find ng.cmd file on your System. It will usually at:

      E:\Users\<USERNAME>\AppData\Roaming\npm
      
    2. Set PATH to this location.

    3. Close existing command window and open new one

    4. Type

      ng version
      

    Also remember to install angular with -g command.

    npm install -g @angular/cli
    
    0 讨论(0)
  • 2021-01-31 02:08

    I have tried with this below Steps and its working fine:-

    Download latest version for nodejs, it should work

    0 讨论(0)
提交回复
热议问题