Why Vercel CLI is Not Working on My Windows Laptop: Modifying Execution Policies

Nitish Kumar Singh

Mar 11, 2024 . 3 min read

Hello developers! In this blog post, I am going to describe an issue and how I resolved it, which is about Windows PowerShell Execution Policies.

Photo by Marc Schulte on Unsplash

A day ago, when I had completed adding a feature to my website and ran the command vercel to deploy changes, I encountered an error with the message: "vercel: File C:\Users\userId\AppData\Roaming\npm\vercel.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".

Then I learned about such a safety feature in the Windows system, which is PowerShell's execution policy. What is PowerShell's execution policy? According to Microsoft Docs: "PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts".

To run Vercel CLI and execute the command vercel, it is necessary to first load Vercel CLI's configuration file, which is "vercel.ps1". But because running scripts is disabled by default on Windows systems, we need to enable running scripts by modifying the Execution Policy.

Before we learn how to modify the execution policy, let's understand more about it. In Windows, the execution policy isn't a security system that restricts users' actions. Instead, it helps us set basic rules and prevents us from unintentionally violating them.

We can set the following execution policies for running scripts in PowerShell according to our requirements:

  • AllSigned: Runs all scripts and configuration files that are signed by trusted publishers and asks before running scripts that are not marked as trusted.
  • Bypass: Runs all scripts and configuration files without any restrictions and there are no warnings or prompts.
  • Default: Sets the default execution policy, which is Restricted for Windows clients and RemoteSigned for Windows servers.
  • RemoteSigned: Same as AllSigned but for server computers.
  • Restricted: This is the default policy that is set in Windows computers that we use physically, and this is the problem of our error.
  • Undefined: There is no execution policy set in the current scope.
  • Unrestricted: This is the default execution policy for non-Windows computers and cannot be changed. Unsigned scripts can run, and there is a risk of running malicious scripts.

Execution policy scope: We can set an execution policy that is effective only in a particular scope. The valid values for Scope are MachinePolicy, UserPolicy, Process, CurrentUser, and LocalMachine. LocalMachine is the default scope when we are setting an execution policy without specifying scope, and their meaning or effectiveness is the same as their name.

To check the effective execution policy for the current PowerShell session, run the Get-ExecutionPolicy command:

Get-ExecutionPolicy

To check all of the execution policies for all scopes that affect the current session and display them in precedence order, run the below command:

Get-ExecutionPolicy -List

We can change the execution policy (therefore it is not a security feature) for a particular scope using PowerShell by running the command below:

Syntax: Set-ExecutionPolicy -ExecutionPolicy <PolicyName> -Scope <scope>
Example: Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser

To resolve my problem, I first changed the execution policy for CurrentUser to AllSigned and ran the vercel command, then it showed the error: "vercel.ps1 is not digitally signed", so I changed it to Unrestricted, and the issue was resolved.

So, this is the issue I had faced and resolved. I hope this post helps you to resolve this issue if you are in it or find this post helpful and informative. Happy coding!

Published on Mar 11, 2024
Comments (undefined)

Read More

How Sign-In and Sign-Up Work in Web Applications

Hello developers! In this blog post, we will learn and understand how user management, including sign-in, sign-up, user verification, logging status, is done in web applications.

Mar 4, 2024

What is a RESTful API - A Confusion Clarification Guide

Hello developers! In this blog post, we will explore all about RESTful APIs, what they are, how they work, and why they are crucial in today's tech landscape.

Mar 3, 2024

Handling User Input in React and Out of React

we will explore how we can handle user input in React and out of React, meaning the ways React provides to handle input and how we can write our own logic to handle user input in a better way than React.

Feb 22, 2024

Dynamic Metadata Generation and Data Fetching at Once in Next.js App Router

Hello developers! In this blog post, we will explore how we can dynamically generate metadata and also fetch server component data by making a single fetch request in the page.js file in the Next.js App Router.

Feb 17, 2024

How to Save Content of a Web Page Element as PDF using JavaScript

Hello developers! In this blog post, I will show you a solution to a question that I have recently faced: how can we save or create a PDF file from the content of a web page element using JavaScript?

Feb 16, 2024

How to Create a Color Picker Web App using JavaScript - Part 3

Hello developers! In this blog post, we will continue the color-picker web app project and understand how to write the rest of JavaScript logic code for our color-picker.

Feb 14, 2024