1

I had an error:

ng : File ....\node_modules\.bin\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

Working with Angular in WebStorm, and this simple command has helped me:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

If anyone knows what this command does, I would appreciate it. I would like to learn a little more, what was the problem and why this command that I found on the Internet has helped me.

Thanks to https://stackoverflow.com/users/7296835/stanley-mohlala for the command.

No ng command worked.

ng generate component xxxxx

neither

ng g component xxxx

neither

ng g c xxxx

I couldn't see the Angular version either, I got an error.

ng version

The error :

ng : File C:\www\angular004560\node_modules\.bin\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Juan Pabon
  • 11
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 21 '22 at 03:27

1 Answers1

2

This error occurs when running ng commands in Windows PowerShell as Windows by default blocks running unsigned powershell scripts because of security concerns, thus the issue. And WebStorm uses the powershell.exe as its default terminal.

You can change the default shell to cmd.exe in Settings | Tools | Terminal, Shell path..., or run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell to overcome the issue.

See https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3 for information about execution policies. See also the answers in Why powershell does not run Angular commands?

lena
  • 90,154
  • 11
  • 145
  • 150