Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

esbuild's install script is blocked or fails when installing Vite with pnpm

ErrorESBuild post-install failed when installing Vite

Short answer

esbuild has an install script and one optional package per platform. pnpm only runs a dependency's build script if you allow it, and strictDepBuilds makes the install fail otherwise. Allow esbuild in allowBuilds. Also avoid --ignore-scripts together with --no-optional, which leaves esbuild with no binary.

  • Applies to pnpm 10 and 11, Node.js 22, Vite 7 and 8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Re-run the install and read what pnpm says about build scripts, then look for pnpm-workspace.yaml entries.

    pnpm install
    cat pnpm-workspace.yaml
  2. 2Match what you see, then jump to its fix

    1. 1pnpm lists esbuild under ignored build scripts, and with strictDepBuilds the install ends with a non-zero exit codepnpm has not been told to run esbuild's build scriptFix
    2. 2The install passes but node_modules/.bin/esbuild is slower than expectedScripts are switched off with --ignore-scriptsFix
    3. 3Both scripts and optional dependencies are disabled, so nothing downloads the esbuild binaryOptional platform packages were skipped tooFix

What does the error look like?

  • ESBuild post-install failed when installing Vite
  • Ignored build scripts (pnpm lists esbuild)
  • pnpm install exits with a non-zero code because of unreviewed dependency build scripts

Cause 1 of 3

pnpm has not been told to run esbuild's build script

1Check

Packages not listed in allowBuilds are disallowed and treated as unreviewed. strictDepBuilds defaults to true, which fails the install while any dependency has an unreviewed build script.

cat pnpm-workspace.yaml

2Fix

Approve esbuild with pnpm approve-builds, or write the entry yourself in pnpm-workspace.yaml. (Older pnpm releases used onlyBuiltDependencies; it was replaced by allowBuilds in pnpm 11.)

# pnpm-workspace.yaml
allowBuilds:
  esbuild: true

3Verify

Install again and run the build.

pnpm install
pnpm exec vite build

Confirmed by pnpm.io

Did this fix it?

Cause 2 of 3

Scripts are switched off with --ignore-scripts

1Check

esbuild's own docs say skipping the install script still leaves a working binary, but the command keeps going through a JavaScript shim and pays an extra node process each call.

grep -rn "ignore-scripts\|ignoreScripts" .npmrc pnpm-workspace.yaml package.json 2>/dev/null

2Fix

Remove the ignore-scripts setting (or flag) for this install, or allow esbuild's script as in the first cause, then install again.

pnpm install

3Verify

Run the build and compare the time.

pnpm exec vite build

Confirmed by esbuild.github.io

Did this fix it?

Cause 3 of 3

Optional platform packages were skipped too

1Check

esbuild's docs say each platform binary is an optional package, and that with both --ignore-scripts and --no-optional the installed package is broken because nothing downloads the real binary. Without optional packages the install script must fetch the binary itself, which can fail behind a proxy or custom registry.

pnpm ls esbuild @esbuild/linux-x64

2Fix

Install with optional dependencies enabled and scripts allowed; fix proxy or registry settings if the script has to download the binary.

pnpm install

3Verify

esbuild runs and prints its version.

pnpm exec esbuild --version

Confirmed by esbuild.github.io

Did this fix it?

How do I stop it coming back?

  • Commit allowBuilds in pnpm-workspace.yaml so CI installs behave like your machine.
  • Do not combine --ignore-scripts with disabling optional dependencies.
  • Keep Node.js and pnpm on current LTS and stable releases.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.