If you're looking for a good alternative to Heroku that allows you to deploy your applications for free, the answer is Render
This is a short guide for deploying a Node.js & Express Typescript application to render.
What you need
- A Render account
- A Github or Gitlab account
- A computer with Node.js and NPM/Yarn
Creating the typescript app
Create a new node project
yarn init
Install typescript, express and typescript Node compiler and their types
yarn add typescript ts-node express
yarn add @types/node @types/express -Dev
Once done, create a src/index.js
file and paste the following into it
import express from "express";
const application = express();
const port = 3000;
application
.get("/", (req, res) => {
res.send({
message: "Hello, World!",
});
})
application.listen(port, () => {
console.log(`Application listening on port ${port}`);
});
In your tsconfig.json
, add
{
"compilerOptions": {
"esModuleInterop": true,
"outDir": "./build"
}
}
You can run the application locally with
npx ts-node ./src/application.ts
Finally, let's deploy the application,
Add the following build
and start
commands to the scripts section of your package.json
:
{
"scripts": {
"build": "tsc",
"start": "node ./build/index.js"
}
}
On Render, Create a new Web Service, choose the free package and give Render permission to access your repository.
Configure your app to use the following settings:
- Environment:
Node
- Build Command:
yarn;
,yarn build
- Start Command:
yarn start
That's it, your application has been deployed for free on Render