Node 18+ Required Version Error — Fix (2026)
The Error
Error: Claude Code requires Node.js 18 or higher. Current version: v16.20.2
Please upgrade Node.js: https://nodejs.org/
This error appears when you try to run Claude Code on a Node.js version older than 18. Claude Code uses ES module features and APIs that require Node 18+.
The Fix
- Check your current Node version:
node --version
- Upgrade with nvm (recommended):
nvm install 22
nvm use 22
nvm alias default 22
- Or upgrade with Homebrew on macOS:
brew update && brew upgrade node
- Reinstall Claude Code on the new Node version:
npm install -g @anthropic-ai/claude-code
claude --version
Why This Happens
Claude Code depends on Node.js features introduced in v18: native fetch API, structuredClone, stable AbortController, and ES module import assertions. These features do not exist in Node 16 or earlier. Many Linux distributions and Docker images ship with older Node versions by default.
If That Doesn’t Work
- If nvm is not installed:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
exec $SHELL
nvm install 22
- If using Docker, update your base image:
FROM node:22-slim
RUN npm install -g @anthropic-ai/claude-code
- If system node is managed by your OS package manager and cannot be changed, use nvm to install a parallel version that takes priority in PATH.
Prevention
Add this to your CLAUDE.md:
# Node.js Version
- Minimum: Node 18. Recommended: Node 22 LTS.
- Add .nvmrc file to project root: echo "22" > .nvmrc
- In CI, always specify: node-version: '22' in GitHub Actions.
See Also
- Claude Code Node Version Mismatch — Fix (2026)
- Wrong Node.js Version in PATH Fix
- Workspace Trust Required for Claude Code — Fix (2026)
Related Error Messages
This fix also applies if you see these related error messages:
npm ERR! code EACCESnpm ERR! code ERESOLVEnpm ERR! peer dep missingfatal: not a git repositoryerror: failed to push some refs
Frequently Asked Questions
Should I use npm or pnpm with Claude Code?
Claude Code works with any Node.js package manager. If your project uses pnpm, add Use pnpm instead of npm for all package operations to your CLAUDE.md so Claude Code respects your toolchain choice.
Why does Claude Code sometimes run npm commands that fail?
Claude Code infers the package manager from lock files. If both package-lock.json and pnpm-lock.yaml exist, it may pick the wrong one. Delete the unused lock file or add an explicit instruction in CLAUDE.md.
How do I verify my npm installation is working?
Run npm doctor to check your npm environment. It validates the registry connection, permissions, cache integrity, and Node.js compatibility in one command.
Why does Claude Code require git?
Claude Code uses git for several core operations: tracking file changes, creating commits, reading blame information, searching history with git log, and managing branches. Without git, these operations fail and Claude Code falls back to less efficient alternatives.
Related Guides
Quick setup → Launch your project with our Project Starter.
Try it: Paste your error into our Error Diagnostic for an instant fix.
- CLAUDE.md Version Control Strategies
- Claude Code for Version Matrix Workflow
- Claude Code Version History and Changes
- TLS Version Negotiation Failure — Fix
Implementation Details
When working with this in Claude Code, pay attention to these practical details:
Project configuration. Add specific instructions to your CLAUDE.md file describing how your project handles this area. Include file paths, naming conventions, and any patterns that differ from common defaults. Claude Code reads CLAUDE.md at the start of every session and uses it to guide all operations.
Testing the setup. After configuration, verify everything works by running a simple test task. Ask Claude Code to perform a read-only operation first (like listing files or reading a config) before moving to write operations. This confirms that permissions, paths, and tools are all correctly configured.
Monitoring and iteration. Track your results over several sessions. If Claude Code consistently makes the same mistake, the fix is usually a more specific CLAUDE.md instruction. If it makes different mistakes each time, the issue is likely in the project setup or toolchain configuration.
Troubleshooting Checklist
When something does not work as expected, check these items in order:
- CLAUDE.md exists at the project root — run
ls -la CLAUDE.mdto verify - Node.js version is 18+ — run
node --versionto check - API key is set — run
echo $ANTHROPIC_API_KEY | head -c 10to verify (shows first 10 characters only) - Disk space is available — run
df -h .to check - Network can reach the API — run
curl -s -o /dev/null -w "%{http_code}" https://api.anthropic.com(should return 401 without auth, meaning the server is reachable) - No conflicting processes — run
ps aux | grep claude | grep -v grepto check for stale sessions