Skip to content

Instantly share code, notes, and snippets.

@gengwg
Created August 7, 2025 05:38
Show Gist options
  • Save gengwg/c45b0f3221436d29a3a1b3ee623d579a to your computer and use it in GitHub Desktop.
Save gengwg/c45b0f3221436d29a3a1b3ee623d579a to your computer and use it in GitHub Desktop.
$ npm install -g @anthropic-ai/claude-code
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gengwg/.npm/_logs/2025-08-07T05_22_23_048Z-debug-0.log

Solution: Configure npm to use a local bin directory

  1. First, create a ~/.npm-global/bin directory if it doesn't exist:

    mkdir -p ~/.npm-global/bin
  2. Add this to your shell config (~/.bashrc, ~/.zshrc, or ~/.profile):

    export PATH=~/.npm-global/bin:$PATH
  3. Update npm configuration:

    npm config set prefix ~/.npm-global
  4. Source your shell config (or restart terminal):

    source ~/.bashrc  # or ~/.zshrc
  5. Now try installing again:

    npm install -g @anthropic-ai/claude-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment