If you are developing an express app using nodejs and want to make it available to the internet then you are in the right place
You need to create your project using node and express js. If you have any code related to file upload using multer or any other package which adds or uploads file to the directory then you can't deploy it to vercel. Vercel does not allow file uploading for projects. For files you have to use Amazon S3 or something else similar to that
Before uploading your project to vercel you need to create a configuration file vercel.json
in the root of your project and add the following content
json{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js"
}
]
}
You can learn about what all these means -> Here but this can get you started
Now open terminal on your project directory and install vercel cli if you haven't yet
npm install -g vercel
# or
yarn add -g vercel
After that you have to inisialize vercel on your project, run the command vercel in the terminal
$ vercel
Vercel CLI 31.4.0
? Set up and deploy “~/Development/Phero/react/brand-shop-backend”? [Y/n]
Asking if you want to setup vercel, just hit enter
? Which scope do you want to deploy to?
● yourName
This shows you a list of available team or profiles, select which you want then hit enter
? Link to existing project? [y/N]
Asking if you want to link this project to a existing project on vercel, the default answer is No
so just hit enter.
? What’s your project’s name? (brand-shop-backend)
Now its asking for a project name, give it a name or leave it as it is by pressing Enter
? In which directory is your code located? ./
If the index.js file is located in the directory where you are running the command then you can just press enter, but if you are using typescript and your build folder is a different one the type the folder path like ./dist
or ./build
Now you can find the project and on vercel dashboard also you will get a production link on the terminal
After deploying if you make any changes to your code in future just run the following command and your project will be updated on vercel too
vercel --prod
Thank you so much for reading this blog
Copythight © All Rights Reserved.