Fix Unable to Run Yarn in Windows Terminal – PowerShell

If you run into an error with your brand new machine when trying to run any custom scripts like npm, yarn or any node modules you might run into an error similar to below.

yarn : File C:Program Filesnodejsyarn.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 + yarn + ~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

To fix it, open PowerShell as administrator, again make sure to run this in PowerShell, not with the regular command prompt (cmd). Copy and paste the code below and run it.

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

This will grant you the necessary permission to run any executable scripts in your PC’s terminal. You only have to do this once and any future yarn or npm commands will run successfully.

Hope this helps with your quick tip on solve why yarn or npm not running on your PC. The same will be true for Ruby’s bundler to manage gems, or Python’s pip package manager.

The post Fix Unable to Run Yarn in Windows Terminal – PowerShell appeared first on Next of Windows.