The term 'ng' is not recognized as the name of a cmdlet

后端 未结 30 820
灰色年华
灰色年华 2020-12-01 00:24

Today, while working through some basic AngularJS Intro, I ran into a problem.

I opened PowerShell to get going on the project. NPM worked.

I was able to in

相关标签:
30条回答
  • 2020-12-01 00:58

    Based on the above answers here is the consolidation.

    1. Run the command npm install -g @angular/cli@project_version
    2. Add the below paths to your environment variables -> System Variables -> Path (For which Admin access is required).

      C:\Users\YourPcAccountName\AppData\Roaming\npm C:\Users\YoutPcAccountName\AppData\Roaming\npm\node_modules\angular-cli\bin Make sure the first value listed as %AppData%\npm

    3. Reopen your command prompt from your project folder and run ng serve.
    0 讨论(0)
  • 2020-12-01 01:01

    Installing angular cli globally solved my problem.

    npm install -g @angular/cli
    
    0 讨论(0)
  • 2020-12-01 01:01

    Also you can run following command to resolve, npm install -g @angular/cli

    0 讨论(0)
  • 2020-12-01 01:04

    I was getting this error in Visual Studio Code while doing ng-build. Running below command in cmd fixed my issue

    npm install -g @angular/cli@latest
    
    0 讨论(0)
  • 2020-12-01 01:05

    You just need to close the visual studio code and restart again. But to get the ng command work in vs code, you need to first compile the project with cmd in administrator mode.

    I was also facing the same problem. But this method resolved it.

    0 讨论(0)
  • 2020-12-01 01:05

    1)Right Clicked on My Computer (windows) 2)Selected Advanced System Settings 3)Clicked "Environment Variables" 4)Under "Path" variable, made the FIRST value listed %AppData%\npm

    Initially: C:\Program Files\Microsoft MPI\Bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;

    After path adding: C:\Program Files\Microsoft MPI\Bin\;%AppData%\npm;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;

    One more thing you can try ,if error still coming, as below 1)go to project location via command prompt:C:\Users\brijeshray\ParentChild> 2)Reinstall or update existing angular as : npm install -g@angular/cli@latest

    3)Go to computer or PC-->Properties-->Advanced system setting -->Environment Variable -->add a path below "User variable"(if 'Path' not there) ==>C:\Users\brijeshray\AppData\Roaming\npm -->save it and restart visual code

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