简体   繁体   中英

ng serve --open not working from Powershell and VS terminal(Powershell)

When I faced this problem, by that time I have already tried triggering this command from Pwershell, both admin and non admin

Got this error:

''' ng: File C:\Users\vishi\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 --open
    • CategoryInfo: SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId: UnauthorizedAccess '''

Then I tried running from CMD as this issue was because of security policies applied on Powershell, then CMD showed this error:

'''The new command requires to be run outside of a project, but a project definition was found at C:\Users\vishi\ImprovApp\angular.json". '''

My question here is, if we are not part of admin group then we can not alter the PS security policy then is there any other way that we can run the nodejs Ng or npm commands????

After executing following command:

PowerShell says "execution of scripts is disabled on this system."

Security policy got updated, and then I triggered "ng serve --open" from VS terminal and then it worked.

details: Execute

Set-ExecutionPolicy RemoteSigned

undo

>Set-ExecutionPolicy Restricted

在此处输入图像描述

Set-ExecutionPolicy RemoteSigned -Scope CurrentUse

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM