Today, while working through some basic AngularJS Intro, I ran into a problem.
I opened PowerShell to get going on the project. NPM worked.
I was able to in
I resolved by following the below steps
1.Right click on command Prompt 2.Run as administrator 3.type npm install -g @angular/cli
In the "Environment Variables"
In the "System variables" section
In the "Path" variable and before "C:\Program Files (x86)\nodejs\"
add => "%AppData%\npm"
Fix: Running scripts is disabled on this system
Open Powershell
Set-ExecutionPolicy RemoteSigned A
(A: YES TO ALL)
Done!
I ran the 'ng serve' command in the command prompt. It compiled the project successfully. Then whatever changes are saved in VS Code, are automatically refreshed in the browser.
PS: I have installed angular globally.
The first path in the path variable needs to be the NPM path. Opening the Node.js command prompt I found that the ng command worked there. I dug into the shortcut and found that it references a command to ensure the first Path variable is NPM. To Fix:
%AppData%\npm
Once I did that I was able to close powershell and reopen and all worked.
Changing the policy to Unrestricted worked for me:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser