Skip to content

Conversation

@natea
Copy link

@natea natea commented Dec 6, 2025

Summary

  • Removes optional=false setting from .npmrc that was preventing esbuild's platform-specific binary from being downloaded
  • Fixes npm install failure with error: Expected "0.21.5" but got "0.18.20"

Problem

The optional=false setting in .npmrc blocked esbuild's optionalDependencies (platform-specific binaries like @esbuild/darwin-arm64). Without the correct binary, esbuild's postinstall validation failed when it found a stale cached binary.

Troubleshooting performed

  1. rm -rf node_modules && npm install - same error
  2. npm cache clean --force - same error
  3. Checked for global esbuild installations - none found
  4. Reviewed npm config → found optional=false in .npmrc
  5. npm install --include=optional - succeeded
  6. Removed optional=false to permanently fix

Test plan

  • Run npm install on a clean clone
  • Verify esbuild binary is correct version (node_modules/.bin/esbuild --version should show 0.21.5)

🤖 Generated with Claude Code

Problem:
npm install was failing with the error:
  Error: Expected "0.21.5" but got "0.18.20"

This occurred because esbuild's install.js validates that the installed
binary version matches the package.json version, but was finding an
older cached binary.

Root cause:
The .npmrc setting `optional=false` was preventing esbuild from
downloading its platform-specific binary package (@esbuild/darwin-arm64,
etc.). These platform binaries are marked as optionalDependencies in
esbuild's package.json.

Without the correct platform binary, esbuild's postinstall script would
find a stale/cached binary from a previous installation and fail the
version check.

Troubleshooting steps taken:
1. Attempted rm -rf node_modules && npm install - same error
2. Cleared npm cache with npm cache clean --force - same error
3. Checked for global esbuild installations - none found
4. Reviewed npm config and found optional=false in .npmrc
5. Ran npm install --include=optional - succeeded
6. Removed optional=false from .npmrc to permanently fix

The fund=false and audit=false settings are retained as they don't
affect dependency installation, only npm's output behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant