PlainError

Home / Coding

npm ERR! code EACCES: permission denied, mkdir '/usr/local/lib/node_modules'

Last checked 2026-10-17 · 2 fixes · reviewed answer

TL;DRnpm cannot create a folder it needs because it lacks permission to write in a protected system directory.

Likely causes

  1. npm is attempting a global install into a system folder that requires elevated rightsmost likely
  2. the target folder has restrictive ownership or permissions set by the operating systempossible

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Install the package inside your current project instead of globallySafe

    Run your npm install command without the -g flag so files go into a folder you already own.

  2. Run the install command with elevated permissionsChanges settings

    Prefix the command with sudo to temporarily allow writing to the system folder.

    sudo npm install -g <package-name>

    ⚠ This grants temporary admin rights; only do this if you understand the command.

If that didn't fix it

Global npm package installs will continue to fail.

When to see a technician

If you are unsure about using sudo or changing system folder permissions, consult a technician.

Did this fix it? Report a problem

Related errors