How To Fix “yarn.ps1 cannot be loaded because running scripts is disabled on this system”

yarn.ps1 cannot be loaded because running scripts is disabled on this system

When running Yarn on Windows, the error “yarn.ps1 cannot be loaded because running scripts is disabled on this system” might appear while other executables of Yarn run just fine. Below we will explain why this problem happens to the PowerShell script and how to fix it.

The Error “yarn.ps1 cannot be loaded because running scripts is disabled on this system”

The Yarn package manager comes with many executables for different platforms. On Windows, you can use yarn.ps1 and yarn.cmd. They are scripting files for two Windows command-line shells: PowerShell and the Command shell.

However, when you run the yarn.ps1 script in PowerShell, you may see this error:

yarn.ps1 cannot be loaded because running scripts is disabled on this system.

As the error message has indicated, your system doesn’t allow you to run PowerShell scripts. This feature has been disabled by its execution policies.

To turn it on and run yarn.ps1, you should get a good understanding of PowerShell’s execution policies and how you can modify them.

PowerShell’s Execution Policies

As you might already know, PowerShell is a task automation program from Microsoft. While it is a cross-platform solution, it is mainly used on Windows.

It comes with not just a command-line shell but also a configuration management framework and a scripting language. That is why many developers, like those of Yarn, choose to write their scripts for the Windows platform.

For security reasons, PowerShell needs to control when it should run scripts or load configuration files. Imposing execution policies makes your system more secure as they can prevent malicious scripts from running without your knowledge.

Remember that these policies only affect PowerShell scripts. If you want to paste the entire content of a script, you are free to do so, even when the script file itself isn’t allowed to execute.

These policies aren’t designed to restrict users from running scripts they want. They exist to prevent them from running malicious scripts unintentionally.

For the current user and local computer, PowerShell saves execution policies in the Windows registry. You don’t need to save them in the PowerShell profile. Meanwhile, all policies for a session are stored in memory and will be lost when the session ends.

There are many policies you can set: AllSigned, Bypass, Default, RemoteSigned, Restricted, Undefined, and Unrestricted. You can set them for different scopes: the current PowerShell session, the current user, and all users in the whole local system.

The default policy for Windows client computers is Restricted. In this mode, PowerShell only allows you to run individual commands, not the whole script. No script files can be executed, including PowerShell profiles (.ps1), module script files (.psm1), and configuration files (.ps1xml).


You will need to set the execution policy, at least for your current session, to a new one that permits scripts. It can be:

  • AllSigned: allows scripts to run but requires them to be signed by trusted publishers, including your own scripts.
  • Bypass: allows scripts to run without prompts or warnings. This is designed for applications where you have your own security model.
  • RemoteSigned: allows scripts to run. It only requires digital signatures if you download them from the internet.
  • Unrestricted: allows every script to run, even if it is unsigned.

This is how you can use the Set-ExecutionPolicy cmdlet to set the execution policy of all users in your system to Unrestricted:

Set-ExecutionPolicy-ExecutionPolicy Unrestricted -Scope LocalMachine

Use this command if you just want to set it for the current session:

Set-ExecutionPolicy-ExecutionPolicy Unrestricted -Scope Process

Now you can run the yarn.ps1 file without trouble:



The error “yarn.ps1 cannot be loaded because running scripts is disabled on this system” occurs when the execution policy of PowerShell prevents you from running scripts. Set it to Bypass, Unrestricted, AllSigned, or RemoteSigned, and run the yarn.ps1 file again.Likewise, follow this guide if you can’t execute the nodemon.ps1 file in Node.js.

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *