esbuild's install script is blocked or fails when installing Vite with pnpm
ESBuild post-install failed when installing ViteShort 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.
Fix it fast
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.yaml2Match what you see, then jump to its fix
- 1
pnpm 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
The install passes but node_modules/.bin/esbuild is slower than expectedScripts are switched off with --ignore-scriptsFix - 3
Both scripts and optional dependencies are disabled, so nothing downloads the esbuild binaryOptional platform packages were skipped tooFix
- 1
What does the error look like?
ESBuild post-install failed when installing ViteIgnored 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.yaml2Fix
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: true3Verify
Install again and run the build.
pnpm install
pnpm exec vite buildConfirmed by pnpm.io
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/null2Fix
Remove the ignore-scripts setting (or flag) for this install, or allow esbuild's script as in the first cause, then install again.
pnpm install3Verify
Run the build and compare the time.
pnpm exec vite buildConfirmed by esbuild.github.io
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-x642Fix
Install with optional dependencies enabled and scripts allowed; fix proxy or registry settings if the script has to download the binary.
pnpm install3Verify
esbuild runs and prints its version.
pnpm exec esbuild --versionConfirmed by esbuild.github.io
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 fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fix