How to fix npm ERR! code EPERM npm ERR! This operation requires administrator privileges in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025· 654 views

This error occurs when npm needs admin privileges for global installs or symlinks on Windows. The fix involves running as administrator or changing npm's global prefix to a user-writable directory.

Quick fix

Fixes npm ERR! code EPERM npm ERR! This operation requires administrator privileges

npm install -g typescript
npm install -g @angular/cli
  1. Run Command Prompt as Administrator (Quick Fix)
  2. Change npm's global prefix to your user directory (Recommended)
  3. Close applications locking files
  4. Enable Windows Developer Mode (For Symlinks/Workspaces)
npm — error
npm install -g typescript
npm install -g @angular/cli
npm ERR! code EPERM
npm ERR! This operation requires administrator privileges

What this error means

This error occurs when npm encounters a file system permission issue while trying to install packages, create symlinks, or modify files in your project directories. The EPERM code stands for "Operation Not Permitted" and typically indicates that your current user account lacks the necessary privileges to perform the operation npm is attempting. On Windows specifically, this error commonly occurs during global package installations, workspace setups with symlinks, or when npm needs to write to system-protected directories like Program Files or the global npm prefix folder. The root cause is usually a mismatch between where npm is configured to install global packages and where your user account has write permissions. Creating symlinks for workspaces or linked packages on Windows requires either administrator privileges or special permissions unless developer mode is enabled.

Typical symptoms

  • npm install -g [package] fails immediately without installing anything globally
  • npm install fails partway through with 'EPERM: operation not permitted, rename'
  • Workspace setups (npm with 'workspaces' field in package.json) fail unless running Command Prompt as administrator
  • npm link command fails when attempting to create symlinks to local packages
  • Error messages reference specific files like 'node_modules/.bin' or binaries that couldn't be created/linked

Common causes

  1. Running npm from a non-administrator Command Prompt when npm's global prefix is in a system-protected directory (e.g., C:\Program Files\nodejs)
  2. npm workspace installations failing because directory symlinks cannot be created without administrator privileges on Windows
  3. Running IDE or file explorer with the project directory open, causing file locks that prevent npm from modifying node_modules
  4. Antivirus software or Windows Defender Ransomware Protection blocking npm's file operations
  5. Files or folders in node_modules marked as read-only, preventing npm from overwriting or deleting them
  6. npm's configured global prefix pointing to a directory where your user account lacks write permissions

How to fix "npm ERR! code EPERM npm ERR! This operation requires administrator privileges"

1Run Command Prompt as Administrator (Quick Fix)

This is the quickest temporary solution for global package installations:

1. Press Windows Key + X and select Terminal (Admin) or Command Prompt (Admin)
2. At the prompt, verify you see "Administrator:" in the title
3. Run your npm command:

bash
npm install -g typescript
npm install -g @angular/cli

Note: This works for one-off global installs but isn't a permanent solution. You'll need admin access each time.

2Change npm's global prefix to your user directory (Recommended)

Reconfigure npm to use a user-writable directory instead of system-protected folders:

1. Open Command Prompt (regular user, no admin needed)
2. Check your current npm prefix:

bash
npm config get prefix

3. Set it to your user's AppData folder:

bash
npm config set prefix "%AppData%\npm"

4. Verify the change:

bash
npm config get prefix

Should return: C:\Users\YourUsername\AppData\Roaming\npm

5. Add this directory to your system PATH if not already included
6. Close and reopen Command Prompt, then test:

bash
npm install -g typescript
3Close applications locking files

Running applications can lock files in your project, preventing npm from modifying them:

1. Close your IDE: Exit Visual Studio Code, Visual Studio, WebStorm, or any editor with your project open
2. Close file explorer: Close any Windows Explorer windows showing your project folder
3. Stop development server: Kill any running npm start, npm run dev, or npm test processes
4. Clear npm cache to ensure a fresh install:

bash
npm cache clean --force

5. Delete existing node_modules and lock file:

bash
rmdir node_modules /s /q
del package-lock.json

6. Retry installation:

bash
npm install
4Enable Windows Developer Mode (For Symlinks/Workspaces)

If you're using npm workspaces or npm link, enabling Developer Mode allows non-admin users to create symlinks:

1. Press Windows Key + I to open Settings
2. Go to Privacy & Security → For developers
3. Toggle Developer Mode to ON
4. Click "Yes" in the popup confirmation
5. Windows will install required developer features (restart may be needed)
6. After enabling, retry your workspace or link command:

bash
npm install
npm link ../local-package
5Check and fix file permissions

Files marked as read-only can cause EPERM errors:

1. Navigate to your project folder in Windows Explorer
2. Right-click the node_modules folder → Properties
3. Check if "Read-only" is checked
- If yes, uncheck it
- Click "Apply", select "Apply changes to this folder, subfolders and files"
- Click OK
4. Also check your project root folder for read-only status
5. If that doesn't work, try changing ownership:
- Right-click node_modules → Properties → Security tab
- Click "Edit" → select your username → click "Full Control" → Apply
6. Retry npm install:

bash
npm install

Advanced notes

Node.js and npm on Windows have historically required administrator privileges for creating directory symlinks due to Windows security policy. Modern versions of Windows 10+ (build 17063+) and Windows 11 now support Developer Mode, which allows non-administrators to create symlinks without special privileges.

An alternative approach that some package managers use (like Yarn) is to leverage Windows junctions instead of true symlinks. Junctions function almost identically to directory symlinks but don't require elevated privileges.

If you're managing Node.js on corporate machines without admin rights, consider portable Node.js distributions (zip archives rather than installers) or using a Node version manager like nvm-windows, which installs everything in user-writable directories.

For CI/CD pipelines on Windows (GitHub Actions, Azure DevOps, AppVeyor), workspace issues can be mitigated by either enabling symlink permissions in the build agent configuration or explicitly running the build step with elevated privileges.

Frequently asked questions

What does "npm ERR! code EPERM npm ERR! This operation requires administrator pri" mean?
This error occurs when npm encounters a file system permission issue while trying to install packages, create symlinks, or modify files in your project directories. The EPERM code stands for "Operation Not Permitted" and typically indicates that your current user account lacks the necessary privileges to perform the operation npm is attempting. On Windows specifically, this error commonly occurs during global package installations, workspace setups with symlinks, or when npm needs to write to system-protected directories like Program Files or the global npm prefix folder.
How do I fix "npm ERR! code EPERM npm ERR! This operation requires administrator pri"?
This error occurs when npm needs admin privileges for global installs or symlinks on Windows. The fix involves running as administrator or changing npm's global prefix to a user-writable directory.
What causes "npm ERR! code EPERM npm ERR! This operation requires administrator pri"?
Running npm from a non-administrator Command Prompt when npm's global prefix is in a system-protected directory (e.g., C:\Program Files\nodejs) npm workspace installations failing because directory symlinks cannot be created without administrator privileges on Windows Running IDE or file explorer with the project directory open, causing file locks that prevent npm from modifying node_modules
Is the "npm ERR! code EPERM npm ERR! This operation requires administrator pri" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading