1

I want to build a new project using sanity. I tried this command - npm install -g @sanity/cli and it was successfully installed. But when I tried this command - sanity init --coupon javascriptmastery2022, I get the following error:

sanity : File C:\Users\asus\AppData\Roaming\npm\sanity.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
+ sanity init --coupon javascriptmastery2022
+ ~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Now how should I fix this error?

  • The link about execution policies appears to contain all the details you need to fix this. It's a PowerShell issue, not a Sanity one. – Geoff Ball Jul 05 '22 at 14:29
  • Does this answer your question? [PowerShell says "execution of scripts is disabled on this system."](https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system) – Geoff Ball Jul 05 '22 at 14:29

2 Answers2

0

Start powershell as administrator and go to the folder where you want to install sanity. Type: Set-ExecutionPolicy -Scope CurrentUser

Then change to Unrestricted

It should work now

T.S.
  • 18,195
  • 11
  • 58
  • 78
0

Run this command in bash in the backend Sanity folder