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

后端 未结 30 822
灰色年华
灰色年华 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 01:11

    I resolved by following the below steps

    1.Right click on command Prompt 2.Run as administrator 3.type npm install -g @angular/cli

    0 讨论(0)
  • In the "Environment Variables"

    In the "System variables" section

    In the "Path" variable and before "C:\Program Files (x86)\nodejs\" add => "%AppData%\npm"

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

    Fix: Running scripts is disabled on this system

    Open Powershell

        Set-ExecutionPolicy RemoteSigned
        A
    

    (A: YES TO ALL)

    Done!

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

    I ran the 'ng serve' command in the command prompt. It compiled the project successfully. Then whatever changes are saved in VS Code, are automatically refreshed in the browser.

    PS: I have installed angular globally.

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

    The first path in the path variable needs to be the NPM path. Opening the Node.js command prompt I found that the ng command worked there. I dug into the shortcut and found that it references a command to ensure the first Path variable is NPM. To Fix:

    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

    Once I did that I was able to close powershell and reopen and all worked.

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

    Changing the policy to Unrestricted worked for me:

    Set-ExecutionPolicy Unrestricted -Scope CurrentUser
    
    0 讨论(0)
提交回复
热议问题