Bundling Your Node.js Express App with esbuild
When setting up a backend node project, I have almost always defaulted to setting up a TypeScript to build the app using the outDir
property in tsconfig.json
.
// tsconfig.json
{
"compilerOptions": {
...
"outDir": "./built",
...
}
}
This worked well for local development as the node_modules
folder sits right there and running the built file is a simple node built/index.js
.
This did not work so well when it came time to deploy the backend code to a server. In order to successfully run…