In short
Install esbuild per project as a dev dependency, with the exact version pinned:
npm install --save-dev --save-exact esbuild npx esbuild --version
Enter fullscreen mode
Exit fullscreen mode
After that, one command builds your first bundle:
npx esbuild src/index.ts --bundle --outfile=dist/index.js
Enter fullscreen mode
Exit fullscreen mode
For watch mode, plugins and anything beyond a few flags, switch to a small build script using the JavaScript API. How that works is shown below. I have been building my own packages and tools this way for years.
Requirements
Node.js and npm in a current LTS version
A project with a package.json . If you don't have one yet, npm init -y creates it.
esbuild itself is written in Go. During installation the npm package fetches the matching binary for your system (macOS, Linux, Windows, each on x64 or ARM).…