Skip to main content
This guide addresses a common installation issue when installing Claude Code on Ubuntu cloud instances (for example, Amazon EC2 or Lightsail). It explains why a global npm install can fail with permission errors and shows a reliable workaround using Claude’s native installer that installs to a user-local directory. Start from a typical Ubuntu shell prompt:
  1. Update and upgrade the system
Always start by updating package lists and installing available upgrades:
Example output you might see:
If a kernel upgrade is included, the system may warn that a reboot is required to load the new kernel:
If you see such a message, schedule or perform a reboot so the new kernel is active before proceeding.
  1. Why global npm install can fail (EACCES permissions)
The Claude Code docs provide an npm-based install command:
On many cloud images, running that command as a non-root user produces an EACCES error because the default global npm directory (commonly /usr/local/lib/node_modules) is owned by root:
Anthropic recommends not using sudo npm install -g ... for their package. Instead, prefer one of the safer alternatives below.
Anthropic’s documentation warns against running sudo npm install -g .... Use a user-local npm prefix, change ownership only if appropriate, or use the native installer that places the binary in ~/.local/bin.
Options to resolve the EACCES error:
  1. System requirements — choose an instance with at least 4 GiB RAM
Claude Code’s documentation lists system requirements; in practice you should provision an instance with at least 4 GiB of RAM and adequate CPU and disk for your workflows. If you’re using Lightsail, select a plan that meets those minimums.
A screenshot of a web documentation page from Anthropic titled "Set up Claude Code," showing system requirements and installation notes with a left navigation menu. The browser window is over an Amazon Lightsail page visible in the background.
If you use Amazon Lightsail or a similar provider, pick a plan that matches the memory/CPU needs — for example, a plan with 4 GiB RAM.
A screenshot of the Amazon Lightsail instance selection page showing network type choices and a grid of pricing tiers from 5 to 384 per month, with the $24/month plan highlighted. Each plan card lists memory, vCPUs, SSD storage, and transfer allowances.
  1. Install the native Claude Code binary (recommended)
The easiest and most reliable method that avoids global npm permissions is to use the native installer provided by Claude. First ensure basic prerequisites are available:
Then run the installer script (you can review the script before running it if you prefer):
Typical successful installer output:
If the installer warns that ~/.local/bin is not in your PATH, add it and reload your shell (or log out and log back in):
After that, verify the installation:
Example (truncated) output from claude --help:
Security tip: Always inspect a script before piping it into bash, especially in production or sensitive environments. Review https://claude.ai/install.sh if you have concerns.
  1. Notes, troubleshooting, and closing
  • Root cause on many cloud images: the default global npm folder is owned by root, causing EACCES when non-root users attempt a global install. Using a user-local npm prefix or the native installer avoids this.
  • If you previously attempted sudo npm install -g @anthropic-ai/claude-code, you can use the migrate-installer command after installing the native binary to cleanly transition:
  • If the claude executable still isn’t found after installing and adjusting PATH, confirm ~/.local/bin/claude exists and that echo $PATH contains ~/.local/bin.
  • Package behavior on specific cloud images may change over time; the native installer is a robust alternative when global npm installs present permission problems.
Example diff snippet referenced in the original instructions:
Further reading and references

Watch Video

Practice Lab