[Angular] ng.ps1 cannot be loaded because running scripts is disabled on this system

Dung Do Tien Nov 16 2020 765

My project was written by Angular version 8, daily I still run normal but today after running the command ng serve -o I got an error as below:

ng : File C:\\Users\\QuizDev\\AppData\\Roaming\\npm\\ng.ps1 cannot be loaded because 
running scripts is disabled on this system. For more information, see 
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ ng serve
+ ~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Please suggest to me if you know any reason.

Have 2 answer(s) found.
  • S

    Sandeep Kumar Nov 16 2020

    You can try to do as below:

    Remove ng.ps1 file from the directory C:/Users/QuizDev/AppData/Roaming/npm/ng.ps1  then try clearing the npm cache at C:/Users/QuizDev/AppData/Roaming//npm-cache

    I hope it works for you.

  • M

    Marry Christ Nov 16 2020

    I also get the same error, I resolved this issue by running the command below in cmd of root project Angular:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser 

    I hope it's work for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close