AI Diagnostic Summary

npm ERR! code EPERM

Well-Documented Error

This error matches known, documented patterns with reliable solutions.

Quick Fix (Most Common Solution)

Seeing "npm ERR! code EPERM"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.

High confidence
What This Error Means

npm cannot perform the requested operation due to file system restrictions.

Frequently documented in developer and vendor support forums.

Based on documented solutions and common real-world fixes.
Not affiliated with browser, OS, or device manufacturers.

New here? Learn why exact error messages matter →

Common Causes
  • File locked by another process
  • Antivirus blocking npm
  • Windows file permission issues
How to Fix
  1. Close all editors and terminals, retry
  2. Temporarily disable antivirus
  3. Run terminal as administrator

Last reviewed: March 2026 How we review solutions

Why This Happens

EPERM stands for "Error PERMission" and means the operating system denied npm the right to perform a file system operation—typically deleting, renaming, or writing a file inside node_modules. Unlike EACCES, which means "you do not have access to this file at all," EPERM specifically means "the operation you attempted is not permitted on this file, even though you can access it." On Windows, this distinction is critical: Windows Explorer or another process may have a handle on a file, which prevents npm from modifying it even though the file permissions allow writes. Antivirus software is the single most common cause on Windows—real-time protection scanners hold brief locks on files as npm writes them, and if npm tries to delete or rename the file during the scan, the OS returns EPERM. On Linux and macOS, EPERM typically means you are running npm install in a directory owned by root (like /usr/local) without sudo, or that immutable flags are set on files. The error is especially frustrating because it often appears to be random—it fails on a different file each time because the race condition between npm's file operations and the locking process depends on timing.

Quick Diagnostic Checklist
  1. Close all other applications that access node_modules (IDEs, dev servers)
  2. Disable antivirus real-time protection temporarily and retry
  3. Delete node_modules and reinstall: rm -rf node_modules && npm install
  4. On Windows, check for file locks: handle.exe (from Sysinternals)
  5. Check file ownership: ls -la node_modules/.package-lock.json
Fixing EPERM on Windows and Linux
# Error output:
# npm ERR! code EPERM
# npm ERR! syscall unlink
# npm ERR! path C:\Users\dev\project\node_modules\.package-lock.json
# npm ERR! errno -4048
# npm ERR! EPERM: operation not permitted, unlink

# Windows Fix:
# Step 1: Close VS Code and any running dev server
$ taskkill /F /IM "Code.exe" /T
$ taskkill /F /IM "node.exe" /T

# Step 2: Add project to antivirus exclusions
# Windows Security > Virus & threat protection > Exclusions
# Add folder: C:\Users\dev\project

# Step 3: Delete node_modules (may need admin prompt)
$ rmdir /s /q node_modules
$ npm cache clean --force
$ npm install

# Linux/macOS Fix:
# Step 1: Check ownership
$ ls -la node_modules/ | head -5
# drwxr-xr-x root root .package-lock.json  <-- Owned by root!

# Step 2: Fix ownership
$ sudo chown -R $(whoami) node_modules
$ npm install

# Step 3: If immutable flag is set (Linux)
$ lsattr node_modules/.package-lock.json
# ----i-------- <-- Immutable flag set
$ sudo chattr -i node_modules/.package-lock.json
Edge Cases & Unusual Scenarios

Windows Controlled Folder Access blocking npm

Windows Ransomware Protection blocks unauthorized applications from modifying protected folders. If your project is in Documents or Desktop, node.exe may be blocked. Add node.exe to the Controlled Folder Access allowed apps list in Windows Security.

npm install run as root created root-owned files

Running sudo npm install creates files owned by root inside node_modules. Subsequent non-sudo npm install attempts fail with EPERM because your user cannot modify root-owned files. Fix with sudo chown -R $(whoami) node_modules and never use sudo for npm install in project directories.

OneDrive or iCloud syncing node_modules

Cloud sync tools may set special attributes on files or hold them open during sync. If your project is in a synced folder, npm file operations conflict with the sync process. Move the project outside the synced directory or add node_modules to the sync exclusion list.

Optional follow-up

Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.

Was this explanation helpful?

Explanations are based on documented fixes, real-world reports, and common system behavior. GetErrorHelp is independent and not affiliated with software vendors, device manufacturers, or service providers.
Frequently Asked Questions

Why does Windows cause EPERM?

Windows has stricter file locking that can conflict with npm operations.

How do I find what is locking files?

Use Process Explorer or handle.exe to find processes locking files.

What is the difference between EPERM and EACCES?

EACCES means the file system permissions do not allow the operation (wrong user or group). EPERM means the operation itself is not permitted regardless of permissions—usually because the file is locked by another process, has immutable attributes, or the OS enforces additional restrictions.

Why does EPERM only happen sometimes?

The error is timing-dependent. Antivirus scans and IDE file watchers lock files briefly. If npm tries to modify the file during that brief window, it gets EPERM. On the next attempt, the lock may have been released. This makes the error appear random.

Should I use sudo to fix EPERM?

Never use sudo for npm install in a project directory—it creates root-owned files that cause more permission problems later. Fix the root cause: close locking processes, disable antivirus scanning of node_modules, or fix file ownership.

Related Resources

Also Known As

Common Search Variations

Related Errors
Still Stuck?

Paste a different error message or upload a screenshot to get help instantly.

Solutions are based on commonly documented fixes and may not apply in all situations.