How to fix npm ERR! code EPERM npm ERR! This operation requires administrator privileges in npm
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- Run Command Prompt as Administrator (Quick Fix)
- Change npm's global prefix to your user directory (Recommended)
- Close applications locking files
- Enable Windows Developer Mode (For Symlinks/Workspaces)
npm install -g typescriptnpm install -g @angular/clinpm ERR! code EPERMnpm 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
- 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
- Antivirus software or Windows Defender Ransomware Protection blocking npm's file operations
- Files or folders in node_modules marked as read-only, preventing npm from overwriting or deleting them
- 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"
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:
npm install -g typescript
npm install -g @angular/cliNote: This works for one-off global installs but isn't a permanent solution. You'll need admin access each time.
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:
npm config get prefix3. Set it to your user's AppData folder:
npm config set prefix "%AppData%\npm"4. Verify the change:
npm config get prefixShould 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:
npm install -g typescriptRunning 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:
npm cache clean --force5. Delete existing node_modules and lock file:
rmdir node_modules /s /q
del package-lock.json6. Retry installation:
npm installIf 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:
npm install
npm link ../local-packageFiles 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:
npm installAdvanced 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
- 📚npm Official Documentation
- 📖Docs: npm CLI(Official Docs)
- 🐙GitHub: npm Windows issues(GitHub)
- 💬SO: npm administrator issues(Stack Overflow)