Deploy Typescript + NODEJS + vercel & .env
For several weeks after Heroku stopped the free tier, I have been scrapping the internet on how to deploy my express, nodejs apps with environment variables. All the resources I came across couldn’t help me archive my goals. If you are like me and in my case, I hope the step-by-step Tut. I have come up with could help you to get your dream out to the world faster.
STEP 1: initialize the node project
run this command in your terminal inside the folder you want to set up your project
* npm init -y
Install All dependencies
yarn add express typescript @types/express @types/node @types/dotenv dotenv ts-node -D
STEP 2: Create a tsconfig.json file
run this command to set up your tsconfig.json file in your project directory
* npx tsc — init — rootDir src — outDir build — esModuleInterop — resolveJsonModule — lib es6 — module commonjs — allowJs true — noImplicitAny true
You can keep the default tsconfig.json
only change “outDir”: “build”, to “outDir”: “dist”,
when the projects build you will get your outDir inside the tsconfig file set to build but change it to dist as illustrated…