Enabling Yarn Script Execution in PowerShell(error): JavaScript Development

Dulal Sandip
3 min readJun 7, 2023

--

“yarn run dev” gives error although it is installed
yarn run dev works after fixing those : “ running scripts is disabled on this system ”

Learn how to enable script execution in PowerShell and optimize your development workflow with Yarn, a popular package manager for JavaScript projects. This comprehensive guide empowers developers to overcome script execution restrictions and leverage Yarn’s capabilities effortlessly. Enhance your productivity by seamlessly working with Yarn and PowerShell.

As a JavaScript developer, harnessing the power of Yarn can greatly enhance your productivity when managing dependencies and executing scripts. However, encountering the “scripts is disabled on this system” error in PowerShell can limit your ability to fully utilize Yarn. In this article, we will delve into enabling script execution in PowerShell, enabling you to seamlessly work with Yarn and optimize your JavaScript development process.

Step 1: Launch PowerShell as Administrator To modify the execution policy, administrative privileges are required. Right-click on the PowerShell icon and select “Run as administrator” from the context menu.

Step 2: Check the Current Execution Policy Once PowerShell opens, use the following command to determine the current execution policy:

By default, the policy is often set to “Restricted.”

Get-ExecutionPolicy

Step 3: Change the Execution Policy To enable script execution, modify the execution policy. Execute the following command to set the execution policy to “RemoteSigned”:

Set-ExecutionPolicy RemoteSigned

This policy allows you to run your own scripts while requiring downloaded scripts to be signed by a trusted publisher. Confirm the change by entering “Y” when prompted.

Step 4: Optimize Development with Yarn and PowerShell With the updated execution policy, you can now optimize your JavaScript development workflow by utilizing Yarn seamlessly within PowerShell. Start by installing project dependencies using the following command:

yarn install

This command downloads and sets up the required dependencies specified in your project’s package.json file.

Step 5: Execute Yarn Scripts Once the dependencies are installed, execute Yarn scripts smoothly using the yarn run command. For instance, to run the dev script, use the following command:

yarn run dev

--

--

Dulal Sandip
Dulal Sandip

Written by Dulal Sandip

Software Engineer, Chief Technology Officer (CTO), Devops

No responses yet