Menu

1 / 5

How to Install esbuild and Set Up Your First Build

DEV Community: esbuild·Marco Starker·1 day ago
#Q5r1TWDi
#devtoesbuild#devto#dev#esbuild#build
Long article (999 words) — no AI summary yet.
Reading 0:00
15s threshold

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).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.