[2023] SecurityError: (:) [], PSSecurityException

▼Error

yarn : The file C:\Users\username\AppData\Roaming\npm\yarn.ps1 cannot be loaded. The file C:\Users\username\AppData\Roaming\npm\yarn.ps1 is not digitally signed. You cannot run this script on the current system. 
At line:1 char:1
+ yarn --version
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

▼Solution

1. Open PowerShell as Administrator

Type “PowerShell” into the Start menu, then right-click and select “Run as Administrator”.

2. Check the Current Execution Policy

Enter the following command to check your current script execution policy:

Get-ExecutionPolicy

3. Change the Execution Policy

Enter the following command to change the script execution policy:

Set-ExecutionPolicy RemoteSigned

The “RemoteSigned” policy allows the execution of local scripts, while only allowing the execution of scripts downloaded from the internet if they are signed.

When a confirmation prompt appears, enter “Y” to approve the policy change.

That’s it! This change in policy should resolve the error and allow you to run Yarn commands in PowerShell.

Remember, changing the execution policy can have security implications. It’s always important to understand the implications of these changes and ensure that you trust the scripts you’re running.

I hope this article can be even just a little helpful to you.!

Happy Developing!

KASATA | Engineer and Entrepreneur

https://twitter.com/IT_makesUsHappy

Leave a Reply