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

后端 未结 30 1056
灰色年华
灰色年华 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条回答
  •  旧时难觅i
    2020-12-01 01:15

    This powershell script worked to add the correct setting to my Environment Variable "Path" ( As a per-user setting. ) It adds: %AppData%\npm ...and then restart the command line that uses "ng"

       $existingPath = [System.Environment]::GetEnvironmentVariable("Path","User")      
       write-host "existing PATH variable is $existingPath"                                          
       $newPath = "%AppData%\npm;$existingPath"                                          
       write-host "new      PATH will be     $newPath"                                               
    
       # update here                                                                                      
       [System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")           
    
       $finalPath = [System.Environment]::GetEnvironmentVariable("Path","User")         
       write-host "final    PATH variable is $finalPath"                                             
    

提交回复
热议问题