7

When I faced this problem, by that time I have already tried triggering this command from Pwershell, both admin and non admin

Got this error:

''' ng : File C:\Users\vishi\AppData\Roaming\npm\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

  • ng serve --open
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess '''

Then I tried running from CMD as this issue was because of security policies applied on Powershell, then CMD showed this error:

'''The new command requires to be run outside of a project, but a project definition was found at C:\Users\vishi\ImprovApp\angular.json". '''

My question here is, if we are not part of admin group then we can not alter the PS security policy then is there any other way that we can run the nodejs Ng or npm commands ????

7
  • 1
    What is the question here? Self-answering is encouraged, but please post the question and answer separately (as if you were answering someone else's question), and cite the other answer by linking to it and then quoting the actual command used :) Commented Oct 19, 2020 at 13:05
  • This is the result of writing a question. and finding the solution before I even submitted it :)) Probably this is my first question on SO. thanks for your response, I appreciate it. Commented Oct 22, 2020 at 10:39
  • You're most welcome! Do you need any additional help to fix it? And welcome to StackOverflow! :) Commented Oct 22, 2020 at 11:09
  • No Jessen, as the question itself contains the answer! Thanks for warm welcome :) Commented Oct 23, 2020 at 17:36
  • 1
    Yeah, but that's not how this site works :) People like me are likely to use the site's search functionality to find unanswered questions for example, and this will keep showing up as unanswered until you actually do. FWIW, you'll get (reputation) points for actually answering and accepting your own answer, which in turn gives you access to more features and privileges, so there's something in it for you as well Commented Oct 23, 2020 at 17:43

2 Answers 2

4

After executing following command:

PowerShell says "execution of scripts is disabled on this system."

Security policy got updated, and then I triggered "ng serve --open" from VS terminal and then it worked.

details: Execute

Set-ExecutionPolicy RemoteSigned

undo

>Set-ExecutionPolicy Restricted
Sign up to request clarification or add additional context in comments.

1 Comment

Just mentioning the right answer out of several: First trigger > Set-ExecutionPolicy RemoteSigned then after completing your task you can undo by: >Set-ExecutionPolicy Restricted
1

enter image description here

Set-ExecutionPolicy RemoteSigned -Scope CurrentUse

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.