Some Common Vercel Errors
Shafia Rahman Chowdhury
Posted on May 15, 2023
When deploying your server-side on Vercel, you may face some common errors sometime. In this blog, I will provide solutions to help you resolve these following errors effortlessly.
1) Error
Cannot GET/your_route_name
Solution
Step-1: Remove "await client.connect ()" in the try block of the run function of your index.js file
Step-2: Go to your vercel.json file and change your dest value to index.js like the one below:
{
"version": 2,
"builds": [
{
"src": "./index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js"
}
]
}
Step-3: Then, run these command on your terminal
vercel
vercel --prod
2) Error
This Serverless Function has crashed
This error have few possible solutions
Solution - 1
Step-1: Remove "await client. connect ()" in the try block of the run function of your index.js file
Step-2: Then, run these command on your terminal
vercel
Vercel --prod
Solution - 2
Step-1: Go to your index.js file, remove app.use(cors()) and write this code instead:
const corsConfig = {
origin: '',
credentials: true,
methods: ['GET', 'POST', 'PUT', 'DELETE']
}
app.use(cors(corsConfig))
app.options("", cors(corsConfig))
Step-2: Then, go to your vercel.json file and copy-paste this code:
{
"version": 2,
"builds": [
{
"src": "./index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/",
"methods": ["GET", "POST", "PATCH", "DELETE", "OPTIONS"]
}
]
}
Step - 3: Then, run these command on your terminal
vercel
Vercel --prod
_If you still see the error change dest value to "dest": "index.js" and deploy the server again using the step-3 command.
Solution-3
Check if you have added your environment variables in your Vercel
Go to Vercel dashboard --> Choose the project --> settings--> Environment Variables
Make sure the enviroment variables you added match with the one in your .env file
Solution-4
If any of the above solutions don’t work, then run this command on your terminal
vercel logs your_production_url
Vercel will let you know if there is any errors in your index.js file.
3) Error
bad credentials Vercel sign up
Step-1: Run this command on your terminal to uninstall Vercel
npm uninstall -g vercel
Step-2: Re-install Vercel globally
npm i -g vercel
Step-3: Now login using the command below:
vercel login
4) Error
This Serverless function has timed out
Visit this blog to resolve this issue:
5) Error
Fix vercel error : A system error occurred: uv_os_gethostname returned ENOSYS (function not implemented)
If you are using Windows 7, you may face this error
Solution:
Step-1: Go to Users -->your_computer_name folder –>
node_modules->vercel->dist->index.js
Step-2: On the top write,
const os=require("os")
os.hostname=()=>"localhost"
Lastly, if you don’t know how to deploy your server using Vercel CLI, follow this blog
For each error, I have provided step-by-step solutions to help you resolve them effectively.
By following the steps outlined in this blog, you can troubleshoot and overcome these errors.
Happy deploying!
Posted on May 15, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024
November 30, 2024