This guide explains a common issue when installing Claude Code on typical Ubuntu virtual machines (EC2, Lightsail, etc.) and provides a safe, recommended workaround using the native installer. It preserves the original troubleshooting steps and shows how to avoid permission problems that occur with global npm installs.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
1 — Update and upgrade the system
Always start by updating package lists and upgrading installed packages:If the system indicates a pending kernel upgrade, plan a reboot. Some kernel upgrades require a restart before the VM behaves as expected — especially on cloud images that use kernel packages from the provider (e.g.,
*-aws kernels).2 — Node.js / npm and a common permissions error
Many older guides instruct installing Claude Code via a global npm package:/usr/local/lib/node_modules. Example failure:
Anthropic explicitly recommends not using
sudo with npm install -g because it can create permission and ownership issues. Prefer user-local installations (see npm ‘prefix’: https://docs.npmjs.com/cli/v9/using-npm/config#prefix), nvm, or the native installer instead.3 — Options to resolve npm permission issues
Choose one of these approaches to avoid global permission errors and maintain a safe system configuration:| Resource / Approach | Use Case | Links / Notes |
|---|---|---|
| nvm (Node Version Manager) | Install Node for your user and use per-user global packages | https://github.com/nvm-sh/nvm |
| npm prefix (user-local global) | Reconfigure npm global install directory under your home directory | https://docs.npmjs.com/cli/v9/using-npm/config#prefix |
| Native installer (recommended) | Quick, VM-friendly install without npm permission issues | See installer steps below |
4 — Recommended: Use the native Claude Code installer (quick and simple)
On a freshly provisioned VM, install curl and git (if not already installed), then run Anthropic’s installer script:claude binary under ~/.local/bin and may prompt that this directory is not in your PATH. Example installer output:
~/.local/bin is not in your PATH, add it permanently to your shell startup file or re-login:
5 — Instance sizing and system requirements
When provisioning a VM for Claude Code, ensure the instance meets Anthropic’s recommended system requirements — in particular, at least 4 GB RAM. Choose an instance size with adequate memory and CPU.

6 — Summary and best practices
- Prefer the native installer to avoid global npm permission issues on VMs.
- If you must use Node/npm, use nvm or configure npm’s
prefixso global packages install under your home directory. - Reboot the VM after kernel upgrades if apt reports a pending kernel; this avoids inconsistent behavior.
- Pick an instance size with at least 4 GB RAM for reliable performance.
- Node.js
- nvm — Node Version Manager
- npm config ‘prefix’
- Anthropic installer: https://claude.ai/install.sh