Skip to content
FR
  1. LuzineDebug
  2. Systems (Windows, macOS, Linux)
  3. File C:\Users\dev\project\script.ps1 cannot be l…
Systems (Windows, macOS, Linux) Beginner ≈ 5 min to fix

Fix "running scripts is disabled on this system" in PowerShell

Error message
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
In short

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.

Be the first to confirm this fix

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

  1. Default Restricted policy on Windows 10 and 11: no .ps1 file can run.
  2. .ps1 launchers installed by tools: npm, npx, yarn, pnpm and global packages, or a Python virtual environment's Activate.ps1.
  3. Downloaded script: a file from the internet carries a zone marker (Mark of the Web); with RemoteSigned, it must be signed or unblocked.
  4. Policy enforced by your company: a Group Policy (GPO) sets MachinePolicy or UserPolicy and overrides your settings.

Step-by-step fix

  1. 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.

    powershell
    Get-ExecutionPolicy -List
  2. 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. RemoteSigned allows 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.

    powershell
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  3. 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.

    powershell
    Unblock-File -Path .\script.ps1
  4. 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
    powershell -ExecutionPolicy Bypass -File .\script.ps1
    # Or for the current window only
    Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
  5. Use the .cmd version of the tools

    npm, npx and yarn also install a .cmd launcher that the policy does not affect. You can call it explicitly, or use Command Prompt (cmd) or Git Bash.

    powershell
    npm.cmd install
    npx.cmd vite
  6. If a company policy blocks it

    If Get-ExecutionPolicy -List shows a value for MachinePolicy or UserPolicy, it comes from a GPO and your commands will not change it. Ask your IT team, or use the .cmd launchers 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 RemoteSigned at CurrentUser scope on every new development machine, rather than Unrestricted or Bypass for the whole machine.
  • Never run a downloaded .ps1 script 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

All Systems (Windows, macOS, Linux) errors →