Fix "running scripts is disabled on this system" in PowerShell
File C:\Users\dev\project\script.ps1 cannot be loaded because running scripts is disabled on this system.
- File C:\Users\dev\AppData\Roaming\npm\npm.ps1 cannot be loaded because running scripts is disabled on this system.
- File C:\Users\dev\project\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system.
- File C:\Users\dev\Downloads\script.ps1 cannot be loaded. The file C:\Users\dev\Downloads\script.ps1 is not digitally signed. You cannot run this script on the current system.
- Impossible de charger le fichier C:\Users\dev\project\script.ps1, car l'exécution de scripts est désactivée sur ce système.
- + CategoryInfo : SecurityError: (:) [], PSSecurityException
PowerShell's execution policy blocks .ps1 files, including those from npm, yarn or a Python venv's Activate.ps1. The recommended fix is Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser: your local scripts run, and downloaded scripts must be signed or unblocked.
What this error means
On client editions of Windows, the default execution policy is Restricted: PowerShell accepts typed commands but refuses to load any .ps1 script file. Many tools install a small .ps1 launcher, so when you type npm or yarn in PowerShell, npm.ps1 is what runs, hence the error. Microsoft states that this policy is not a security boundary but a safeguard against accidentally running scripts, for example ones received by email or downloaded.
Common causes
- Default
Restrictedpolicy on Windows 10 and 11: no.ps1file can run. .ps1launchers installed by tools: npm, npx, yarn, pnpm and global packages, or a Python virtual environment'sActivate.ps1.- Downloaded script: a file from the internet carries a zone marker (Mark of the Web); with
RemoteSigned, it must be signed or unblocked. - Policy enforced by your company: a Group Policy (GPO) sets
MachinePolicyorUserPolicyand overrides your settings.
Step-by-step fix
-
Check the current policy
Show the policy for each scope. The first defined scope in the list (top to bottom) is the one that applies.
Get-ExecutionPolicy -List -
Allow your local scripts for your account
This is the recommended fix for a development machine. It needs no admin rights and only affects your user.
RemoteSignedallows scripts created on your machine and requires a signature for downloaded ones. Then reopen PowerShell. On Windows 11, the same setting exists in Settings > System > For developers > PowerShell.Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -
Unblock a trusted downloaded script
If the script comes from the internet, read it first to check what it does, then remove its zone marker. Only do this for a source you know.
Unblock-File -Path .\script.ps1 -
Run once without changing the policy
For a single script, you can bypass the policy for one process. The setting is gone when the window closes, but it disables the safeguard: keep it for scripts you have read.
powershell -ExecutionPolicy Bypass -File .\script.ps1 # Or for the current window only Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -
Use the .cmd version of the tools
npm, npx and yarn also install a
.cmdlauncher that the policy does not affect. You can call it explicitly, or use Command Prompt (cmd) or Git Bash.npm.cmd install npx.cmd vite -
If a company policy blocks it
If
Get-ExecutionPolicy -Listshows a value forMachinePolicyorUserPolicy, it comes from a GPO and your commands will not change it. Ask your IT team, or use the.cmdlaunchers in the meantime.
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Set
RemoteSignedatCurrentUserscope on every new development machine, rather thanUnrestrictedorBypassfor the whole machine. - Never run a downloaded
.ps1script without reading it, and only unblock those from trusted sources. - Windows PowerShell 5.1 and PowerShell 7 each keep their own setting: run the command in every version you use.
Frequently asked questions
Is RemoteSigned safe?
It is the recommended trade-off for development: your local scripts run and scripts from the internet stay blocked unless signed. Avoid permanent Unrestricted and Bypass, which remove every safeguard.
Do I need to be admin for Set-ExecutionPolicy?
Not with -Scope CurrentUser. Only the LocalMachine scope (the default when you specify nothing) requires an elevated console.
Why does npm work in cmd but not in PowerShell?
cmd runs npm.cmd, which is not subject to the execution policy. PowerShell prefers npm.ps1, which is blocked while the policy is Restricted.
Useful tools for this error
More Systems (Windows, macOS, Linux) errors
- Fix "command not found" and "is not recognized as an internal or external command"
- Fix "xcrun: error: invalid active developer path" on macOS
- Fix "SSL certificate problem: unable to get local issuer certificate" (git, curl, pip, npm)
- Fix "user is not in the sudoers file. This incident will be reported."
- Fix "/bin/bash^M: bad interpreter: No such file or directory"
- Fix "E: Could not get lock /var/lib/dpkg/lock-frontend" (apt, Ubuntu, Debian)
- Fix "App is damaged and can't be opened" on macOS (Gatekeeper)