Current:
ng version
Angular CLI: 9.1.12
Node: 14.9.0
OS: win32 x64
Angular: 9.1.12
… animations, cli, common, compiler, compiler-cli, core, forms
… language-service, localize, platform-browser
… platform-browser-dynamic, router
Ivy Workspace: Yes
Out of the blue, PowerShell on executing “ng version” complains with:
ng : AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system
Therefore check execution policy:
Get-ExecutionPolicy
Restricted
Solution, run PowerShell in admin mode and increase permissions:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-ExecutionPolicy -List
Scope ExecutionPolicy ----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Restricted
The RemoteSigned policy does not seem without security risks but I am unable to find advisories on this topic.
Tip from this article, update not only local version but also global version of Angular:
npm uninstall -g @angular-cli
npm install -g @angular/cli@latest
and then local:
ng update @angular/cli @angular/core
First attempt fails with
Package "@ngx-i18nsupport/tooling" has an incompatible peer dependency to "@angular/common
Try again with force:
ng update --force @angular/cli @angular/core
Production update as before, no surprises. For code changes see Github.
Reading list
- medium.com/@balramchavan/how-to-upgrade-angular-version-to-latest-release-version-10-48cd64ad21b3
- https://angular.io/guide/updating-to-version-10
- https://stackoverflow.com/questions/58032631/why-powershell-does-not-run-angular-commands
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
- https://www.thecodebuzz.com/angular-powershell-ng-ps1-can-not-be-loaded-and-not-digitally-signed/