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 <noreply@anthropic.com>