esbuild: JavaScript/CSS Bundler (Linux RISC-V 64-bit)
esbuild is a modern, extremely fast JavaScript and CSS bundler and minifier written in Go, not JavaScript. It aims to significantly improve build tool performance by leveraging parallelism and low-level optimizations, often achieving speeds 10-100 times faster than other bundlers like Webpack or Rollup. Key features include built-in support for ES6 and CommonJS modules, TypeScript, JSX, tree-shaking, source maps, and minification. It provides a straightforward API for both CLI and programmatic use in JavaScript/TypeScript and Go. The main `esbuild` package dynamically installs platform-specific binaries; `esbuild-linux-riscv64` is one such binary for Linux RISC-V 64-bit architectures. The latest stable version of the core `esbuild` is 0.28.0 (as of April 2026), with frequent patch and minor releases addressing bugs and adding features. It is widely adopted, integrated into tools like Vite, Angular (since v17), Ruby on Rails (since v7), and Netlify Functions.
Common errors
-
Error: Cannot find module 'esbuild/lib/main' (or similar path)
cause The native esbuild binary for your platform was not correctly installed or could not be found, often due to network issues during installation or incorrect npm flags.fixEnsure you have a stable internet connection. Try running `npm install esbuild` without `--no-optional` or `--ignore-scripts`. If issues persist, manually verify the `@esbuild/<platform>` package is present in `node_modules` for your OS and architecture. -
✘ [ERROR] Could not resolve "some-module" (src/index.js:3:19)
cause esbuild could not locate the imported module. This usually means the module is not installed, misspelled, or esbuild's module resolution rules are not configured correctly for your project structure or specific module type.fixVerify the module is installed via `npm install` or `yarn add`. Check for typos in the import path. If it's a Node.js built-in, add it to `external` options. For complex resolutions, consider `alias` or `plugins` for custom handling. -
✘ [ERROR] Expected ";" but found "}" (src/index.js:10:1)
cause A syntax error exists in your source code, preventing esbuild from parsing it correctly.fixReview the indicated file and line number. Ensure your JavaScript/TypeScript code adheres to correct syntax for the targeted ES version. Use a linter (e.g., ESLint) to catch syntax errors proactively. -
The "esbuild" command must be run with Node.js version 12 or higher.
cause The installed Node.js version does not meet the minimum requirement specified by esbuild's `engines` field (`"node": ">=12"`).fixUpgrade your Node.js environment to version 12 or higher. Use a Node Version Manager (nvm, fnm, volta) to easily switch and manage Node.js versions.
Warnings
- breaking esbuild `v0.27.0` (and later minor releases) introduced deliberate backwards-incompatible changes, including updated Go compiler requirements impacting minimum Linux kernel and macOS versions. Always pin the exact version of `esbuild` in your `package.json` (e.g., `"esbuild": "0.27.0"`) or use a caret range that accepts only patch upgrades (`^0.26.0`, `~0.26.0`) to avoid unexpected breakages.
- gotcha esbuild is built in Go and relies on native executables for performance. Platform-specific binaries (like `esbuild-linux-riscv64`) are typically installed as optional dependencies. Issues can arise if the correct binary cannot be found or installed, or if npm flags like `--no-optional` or `--ignore-scripts` are used during installation, hindering esbuild's ability to download its binary fallback.
- gotcha Unlike many other bundlers (e.g., Webpack), esbuild does not support external configuration files like `webpack.config.js`. All configurations must be passed either via command-line arguments or programmatically through its JavaScript/TypeScript API.
- gotcha When bundling for Node.js, built-in Node.js modules (like `fs`, `path`, `http`, `https`) are not automatically excluded and will result in build errors like `Could not resolve "https"`.
- gotcha esbuild's TypeScript loader performs transpilation only; it does not do type-checking. Type errors will not cause an esbuild build to fail, potentially leading to runtime issues.
Install
-
npm install esbuild-linux-riscv64 -
yarn add esbuild-linux-riscv64 -
pnpm add esbuild-linux-riscv64
Imports
- build
const { build } = require('esbuild')import { build } from 'esbuild' - transform
const transform = require('esbuild').transformimport { transform } from 'esbuild' - BuildOptions
import type { BuildOptions } from 'esbuild'
Quickstart
import { build } from 'esbuild';
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
const entryPoint = join(process.cwd(), 'src/main.ts');
const outputDir = join(process.cwd(), 'dist');
const outputFile = join(outputDir, 'bundle.js');
const content = `
// src/main.ts
import { add } from './utils';
console.log('Hello from esbuild!');
const result = add(5, 3);
console.log('5 + 3 =', result);
`;
const utilsContent = `
// src/utils.ts
export function add(a: number, b: number): number {
return a + b;
}
`;
// Create dummy source files for demonstration
writeFileSync(entryPoint, content);
writeFileSync(join(process.cwd(), 'src/utils.ts'), utilsContent);
// Ensure output directory exists
import { mkdirSync } from 'node:fs';
mkdirSync(outputDir, { recursive: true });
async function runBuild() {
try {
await build({
entryPoints: [entryPoint],
bundle: true,
outfile: outputFile,
platform: 'node',
format: 'esm',
target: 'es2022',
minify: true,
sourcemap: true,
logLevel: 'info',
external: ['node:fs', 'node:path'], // Mark Node.js built-ins as external
});
console.log('Build successful!');
const bundledCode = readFileSync(outputFile, 'utf-8');
console.log('\n--- Bundled Code (truncated) ---');
console.log(bundledCode.substring(0, 500) + '...');
} catch (e) {
console.error('Build failed:', e.message);
process.exit(1);
}
}
runBuild();