Back to blog
May 01, 2024
2 min read

Fixing the Error "Running scripts is disabled on this system"

To fix the error "Running scripts is disabled", adjust PowerShell's execution policy to allow script execution.

Visual Studio Code Explorer

Photo by Stéphan Valentin on Unsplash

When you’re developing applications and see an error like this, it means that your PowerShell environment has a security policy that prevents scripts from running. This is a security measure to protect your system, but it can be a hurdle for developers. Here’s how you can fix this error:

Open PowerShell as Administrator

Find PowerShell in the Start menu, right-click on it, and choose “Run as Administrator.” This allows you to change the security policy.

Check the Current Execution Policy

To understand the current security setting, use this command:

Get-ExecutionPolicy

Change the Execution Policy

To allow scripts to run, you can set the execution policy to RemoteSigned or Bypass. RemoteSigned allows scripts created locally to run, while requiring digital signatures for scripts downloaded from the internet. Bypass allows any script to run, which is less secure but might be necessary for development.

To change the execution policy, run this command in PowerShell:

Set-ExecutionPolicy RemoteSigned

If you prefer a more permissive setting, use Bypass:

Set-ExecutionPolicy Bypass

Confirm the Change

If prompted to confirm, type Y and press Enter.

Try Running Your Script Again

Now that the execution policy has been updated, like try running your npm command again:

npm run dev

If these steps don’t solve the problem, ensure that your PowerShell environment is running with sufficient permissions, and check if there are any additional security software or policies that might be blocking script execution.