Some Common Vercel Errors

shafia

Shafia Rahman Chowdhury

Posted on May 15, 2023

Some Common Vercel Errors

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"
       }
   ]
}


Enter fullscreen mode Exit fullscreen mode

Step-3: Then, run these command on your terminal



vercel
vercel --prod


Enter fullscreen mode Exit fullscreen mode

2) Error

This Serverless Function has crashed

Image description

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


Enter fullscreen mode Exit fullscreen mode

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


Enter fullscreen mode Exit fullscreen mode

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"]
        }
    ]
}


Enter fullscreen mode Exit fullscreen mode

Step - 3: Then, run these command on your terminal



vercel
Vercel --prod


Enter fullscreen mode Exit fullscreen mode

_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


Enter fullscreen mode Exit fullscreen mode

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


Enter fullscreen mode Exit fullscreen mode

Step-2: Re-install Vercel globally



npm i -g vercel


Enter fullscreen mode Exit fullscreen mode

Step-3: Now login using the command below:



vercel login


Enter fullscreen mode Exit fullscreen mode

4) Error

This Serverless function has timed out

Visit this blog to resolve this issue:

https://dev.to/shafia/the-errors-you-may-face-for-not-whitelisting-the-ip-address-0000-in-your-mongodb-network-access-32f8

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"


Enter fullscreen mode Exit fullscreen mode

Lastly, if you don’t know how to deploy your server using Vercel CLI, follow this blog

https://medium.com/@shafiarahmanchy13/how-to-deploy-a-node-express-server-using-vercel-cli-f0a464d4e88c

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!

💖 💪 🙅 🚩
shafia
Shafia Rahman Chowdhury

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