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

前端 未结 19 1299
轻奢々
轻奢々 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:10

    make sure environment variables are set properly.

    control panel-> system->advanced system settings-> select advanced Tab->
    click on environment variables
    

    and make sure in the path below line is available

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

    here username will get changed based on the user

    .

    still if its not working yourenvironment variables are not getting reflected so please restart your machine it will work fine

    if still you are facing issue your angular cli is not installed properly

    please run below commands for reinstalling

       npm uninstall -g @angular/cli
    
        npm cache clean    or   npm cache clean  --force
    
        npm install -g @angular/cli@latest
    
    0 讨论(0)
  • 2021-01-31 02:11

    You can also try:

     > npm run ng <command>
    
    0 讨论(0)
  • 2021-01-31 02:12

    What worked for me was that I was missing an file

    .npmrc
    

    which is located under

    C:\Users\username
    

    That file should contain

    prefix=$(APPDATA)\npm
    

    Also my environment path was pointing to my admin user

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

    You should not add C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng to your PATH. There is only a javascript file which you cannot use in terminal.

    You need ng.cmd which is probably located at %AppData%\Roaming\npm. Make sure this path is included in your PATH variable.

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

    No need to uninstall angular/cli.

    1. You just need to make sure the PATH to npm is in your environment PATH and at the top.

    C:\Users\yourusername\AppData\Roaming\npm

    1. Then close whatever git or command client your using and run ng-v again and should work
    0 讨论(0)
  • 2021-01-31 02:15

    You should add the path where ng.cmd located. By default, it should be located on C:\Users\user\AppData\Roaming\npm

    NB: Here "user" may vary as per your pc username!

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