Harshdeep Singh
Harshdeep Singh

Reputation: 54

How to fix error while using sanity init coupon?

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?

Upvotes: 1

Views: 844

Answers (3)

Nadun Udana
Nadun Udana

Reputation: 1

A Quick fix : If you are using visual studio code, Please check what terminal u use.. In my case I have been using powershell and when I changed that to CMD it worked like a magic.. Happy coding..

Upvotes: 0

Komal Mano
Komal Mano

Reputation: 1

Run this command in bash in the backend Sanity folder

Upvotes: 0

GoldenSlime
GoldenSlime

Reputation: 1

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

Upvotes: 0

Related Questions