1

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 ????

Mathias R. Jessen
  • 106,010
  • 8
  • 112
  • 163
Vishesh
  • 11
  • 5
  • 1
    What is the question here? [Self-answering is encouraged](https://stackoverflow.com/help/self-answer), but please post the question and answer separately (as if you were answering someone else's question), and [cite the other answer](https://stackoverflow.com/help/referencing) by linking to it and then quoting the actual command used :) – Mathias R. Jessen Oct 19 '20 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. – Vishesh Oct 22 '20 at 10:39
  • You're most welcome! Do you need any additional help to fix it? And welcome to StackOverflow! :) – Mathias R. Jessen Oct 22 '20 at 11:09
  • No Jessen, as the question itself contains the answer! Thanks for warm welcome :) – Vishesh Oct 23 '20 at 17:36
  • 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 – Mathias R. Jessen Oct 23 '20 at 17:43
  • I have added some extra lines for to be answered at bottom of complete scenario.. please let me know answer for that? – Vishesh Oct 23 '20 at 17:46
  • Beautiful! Your're a real StackOverflow netizen now! :D I'd still strongly suggest adding _the actual command you ran_ to your answer (the post you linked to has 36(!) answers) :) – Mathias R. Jessen Oct 23 '20 at 18:23

1 Answers1

0

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
Vishesh
  • 11
  • 5
  • 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 – Vishesh Oct 26 '20 at 08:02