This document contains the original instructions that led to the creation of this Claude Code fix tool.
I was experiencing a React error #327 when trying to migrate Claude Code from global to local installation on macOS:
claude /migrate-installer
[After selecting "Yes, proceed" to trust the folder]
✢ Removing global npm installation
file:///Users/spaceplushy/node_modules/@anthropic-ai/claude-code/cli.js:65
Error: Minified React error #327; visit https://reactjs.org/docs/error-decoder.html?invariant=327
at PW (file:///Users/spaceplushy/node_modules/@anthropic-ai/claude-code/cli.js:67:34915)
[stack trace truncated]
Node.js v22.16.0
- OS: macOS (Mac mini)
- Node.js version: v22.16.0 (not LTS - this was identified as part of the issue)
- User: spaceplushy
- Shell: zsh
- Current directory: /Users/spaceplushy
I needed a complete solution that would:
- Create comprehensive diagnostic and fix scripts that I could run directly
- Work entirely within a controlled directory (
/Users/spaceplushy/Desktop/claude-fix/) - Provide complete, working bash scripts with all necessary code, error handling, and logic
- Handle all edge cases and provide clear feedback
- Be production-ready with proper error handling, not just examples
- I was on v22.16.0 (non-LTS)
- The script needed to detect if nvm was installed, install it if not
- Install Node.js v20 LTS or v22 LTS and set as default
- npm prefix ownership issues
- Global node_modules permissions
- User vs system installations
- Homebrew Node installations
- System Node installations
- nvm/fnm installations
- Any Claude Code in ~/.claude, node_modules, or global
This indicated component lifecycle issues, likely from:
- Partial installation state
- Corrupted cache
- Version mismatches
Creates the directory structure and sets up the working environment.
Comprehensive system analysis including:
- All Node/npm installations (system, nvm, homebrew, fnm)
- Global npm packages (especially @anthropic-ai/claude-code)
- npm directory permissions
- All Claude Code installations system-wide
- Conflicting environment variables
- Multiple package managers
- npm cache location and state
- .npmrc files that might cause issues
Complete fix implementation:
- Works entirely within the working directory
- Backs up existing Claude configurations
- Logs all actions
- Completely removes all Claude Code installations
- Cleans npm cache
- Fixes npm permission issues
- Installs correct Node.js LTS version
- Reinstalls Claude Code properly
- Tests the installation
Alternative containerized solution with:
- Dockerfile for Claude Code
- Container build process
- Volume mounts for work directory
- Easy-use alias
Safety net in case something goes wrong.
The solution was successful when:
- ✅
claude --versionreturns version without errors - ✅
which claudeshows a single, accessible path - ✅ No React errors occur
- ✅ Migration tool works OR Claude works without migration
The master script created a comprehensive solution that:
- Diagnosed the system and identified all conflicts
- Backed up existing configurations safely
- Cleaned corrupted installations completely
- Fixed npm permissions with proper global directory setup
- Maintained Node.js version (since current version worked after cleanup)
- Reinstalled Claude Code with fresh, clean installation
- Verified functionality with comprehensive testing
- Cleaned up automatically when done
✅ Success! Claude Code now works properly:
- Version: 1.0.43 (Claude Code)
- No React errors
- All functionality verified
- Clean installation state
This tool can now help others experiencing similar Claude Code installation issues.