If you are working on Angular on Windows, you might run into an issue that says, “ng.ps1 cannot be loaded because running scripts is disabled” error. It usually appears when you run ng serve, ng build, or any Angular CLI command in PowerShell or cmd (Command Prompt).
You know, this problem happens because Windows blocks certain scripts by default. Angular CLI installs a PowerShell Script called ng.ps1 and this time, PowerShell refuses to run it unless you change the execution settings for security purposes.

Understand why this error happens!
Angular installs its CLI tools inside this folder:
C:Users<YourUser>AppDataRoamingnpm
When you run any ng command, your PowerShell tries to run the file ng.ps1. If your system’s execution policy is set to Restricted, PowerShell blocks the script and throws the given error.
Windows does this to prevent untrusted scripts from running automatically, but also note that it also blocks safe developer scripts like Angular CLI.
Here's some good news: the fix is simple. Try out the best-working solutions, which are safest and most commonly used.
Solution 1: Allow scripts only for your user (recommended)
This is the best way and a good practice too, because it updates the execution policy for your account only. It doesn’t affect system-wide security.
1. Open PowerShell as Administrator,
2. Run this command,
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
3. Close and reopen VS Code (or your respective IDE)
4. Run below command:
ng serve
By performing these steps this allows locally created scripts (like Angular CLI) to run without touching global system settings. It works for most developers; this fix is enough.
Solution 2: Allow script execution only for the current session
If you are planning not to change any policy permanently for your system or your account, you can bypass it temporarily using this method. This is safe because it resets automatically after you close the terminal (or PowerShell or CMD).
Run this command in your PowerShell terminal:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
You can now run Angular commands normally. When you close the window, the policy returns to default behaviour.
Solution 3: Switch to Command Prompt instead of PowerShell
If you prefer not to change any execution policy at all, or you have restrictions in your organisation, then this solution will work for you. Simply switch your terminal.
In your VS Code:
- Press
Ctrl + Shift + P - Search Terminal: Select Default Profile
- Choose Command Prompt
- Open a new terminal and run:
ng serve --open
In this fix, the CMD doesn’t enforce PowerShell’s restrictions, so Angular CLI works without any errors.
Solution 4: Reinstall Angular CLI (if ng.ps1 is corrupted)
Sometimes the ng.ps1 file gets corrupted or deleted by your organisation’s security or strict policy. If the above fixes don’t help, reinstalling the Angular CLI globally always works.
Run these commands:
npm uninstall -g @angular/cli
npm install -g @angular/cli
Then try again:
ng serve
A fresh install usually fixes any script-related issues.
Solution 5: Check if your Node and NPM path is correctly set
If your system can’t find the ng.ps1 file or the PATH variable is misconfigured, you can reset it by reinstalling Node.js or manually adding this path:
C:Users<YourUser>AppDataRoamingnpm
Once the PATH is correct, PowerShell will be able to find the Angular CLI script.
Wrapping Up…
Once the issue is fixed, you’ll be able to run Angular CLI commands like ng serve or ng build without interruptions. Tell me, which solution worked for you? — If you find a new way, please comment it below so other developers can also save some time! Time is precious, you know!
Discover more from 9Mood
Subscribe to get the latest posts sent to your email.














0 Comments