How to fix npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocked by antivirus in npm

npmBEGINNERHIGHUpdated Dec 5, 2025· 438 views

This error occurs when antivirus software blocks npm from modifying files in node_modules. The fix involves adding your project folder to antivirus exclusions or temporarily disabling real-time protection.

Quick fix

Fixes npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocked by antivirus

npm install
  1. Add your project folder to antivirus exclusions (Windows Defender)
  2. Temporarily disable real-time antivirus protection
  3. Clear npm cache and delete node_modules, then reinstall
  4. Run npm install with administrator privileges
npm — error
npm install
npm ERR! code EPERM
npm ERR! Operation not permitted - possibly blocked by antivirus
shell
npm install

What this error means

The EPERM error stands for "Error: PERMission Denied" and indicates that npm cannot perform a critical file operation (delete, write, rename, or link files) in your node_modules directory or npm cache. When antivirus software is the culprit, your system's security tools are actively scanning, locking, or preventing npm from completing these operations. This commonly happens because modern antivirus programs—like Windows Defender, McAfee, and Norton—monitor all file system activity in real-time, and they may flag npm's rapid creation and modification of thousands of files during package installation as suspicious or lock files that npm needs to access. The error itself is harmless, but it blocks your project from progressing until the underlying permission conflict is resolved.

Typical symptoms

  • npm install fails partway through with 'EPERM: operation not permitted, rename' or 'unlink' errors
  • npm install works sometimes but fails randomly on retry
  • npm install completes much slower than normal (15+ minutes for moderate projects)
  • Error messages reference paths deep in node_modules with file access failures
  • Running npm install a second time after failure sometimes succeeds

Common causes

  1. Windows Defender real-time protection scanning node_modules files while npm tries to modify them, causing file lock conflicts
  2. McAfee or Norton antivirus with aggressive real-time scanning interfering with rapid file creation during package extraction
  3. Windows Defender Tamper Protection feature blocking npm's write access to protected system folders
  4. Ransomware Protection in Windows Security scanning the Downloads or AppData folders where npm caches packages
  5. Project or npm cache directories located on a network share being scanned by antivirus
  6. IDE or text editor holding file handles open while npm tries to delete or modify files

How to fix "npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocked by antivirus"

1Add your project folder to antivirus exclusions (Windows Defender)

This is the safest solution as it prevents antivirus from interfering without disabling security entirely.

For Windows Defender:

1. Open Windows Security by pressing Windows Key + I to open Settings
2. Go to Virus & threat protection > Manage settings
3. Under "Exclusions," click Add or remove exclusions
4. Click Add an exclusion and choose Folder
5. Browse to and select your project directory (e.g., C:\Users\YourName\Projects\my-app)
6. Repeat for your npm global folder (typically C:\Users\YourName\AppData\Roaming\npm)
7. Close Windows Security

Now retry your npm install:

bash
npm install
2Temporarily disable real-time antivirus protection

If adding folder exclusions doesn't resolve the issue, temporarily disable real-time scanning for a single npm install session.

For Windows Defender:

1. Open Windows Security (Windows Key + I > Virus & threat protection)
2. Click Manage settings
3. Under "Real-time protection," toggle the switch to Off
4. Open Command Prompt or PowerShell and run:

bash
npm install

5. Once npm install completes successfully, turn real-time protection back On in Windows Security

Note: Only disable protection temporarily during the npm install—keep your antivirus running for ongoing system protection.

3Clear npm cache and delete node_modules, then reinstall

Sometimes npm's cache can become corrupted or locked by antivirus. Clearing the cache and starting fresh often resolves the issue:

bash
# Stop any running npm processes or development servers first

# Clear npm cache
npm cache clean --force
npm cache verify

# Delete the corrupted node_modules folder
rm -r node_modules
# On Windows PowerShell:
# Remove-Item -Recurse -Force node_modules

# Delete package-lock.json to force a fresh lock file
rm package-lock.json

# Reinstall dependencies
npm install
4Run npm install with administrator privileges

Windows antivirus sometimes blocks file operations for non-admin processes. Elevating privileges can allow npm to complete:

1. Right-click Command Prompt or PowerShell and select Run as administrator
2. Navigate to your project directory:

bash
cd C:\Users\YourName\Projects\my-app

3. Run npm install:

bash
npm install

The "Run as administrator" window title will show "Administrator" to confirm elevation.

5Exclude npm's global and cache directories from antivirus scanning

Beyond your project folder, npm has a global configuration directory and cache. Antivirus scanning these locations can also trigger EPERM errors.

First, find your npm directories:

bash
npm config get prefix     # Shows global npm location
npm config get cache      # Shows cache location

On Windows, these are typically:
- Global modules: C:\Users\YourName\AppData\Roaming\npm
- Cache: C:\Users\YourName\AppData\Local\npm-cache

Add both directories to your antivirus exclusions (see Step 1 for instructions).

6Close IDEs and editors before running npm install

Visual Studio Code, WebStorm, and other editors may lock files in your project, which antivirus can interpret as permission issues:

1. Close all instances of your IDE (VS Code, WebStorm, Sublime, etc.)
2. Stop any running development servers (webpack-dev-server, Next.js dev server, etc.)
3. Open a fresh Command Prompt or PowerShell (not integrated into an IDE)
4. Navigate to your project and run:

bash
npm install

5. Once npm completes successfully, reopen your IDE

Advanced notes

Real-time antivirus scanning impacts npm performance significantly because npm operations involve creating and extracting thousands of files during a single npm install. Windows Defender alone can increase install times by 3-4x (from ~4 minutes to 15+ minutes on typical projects). McAfee and Norton are often worse offenders because their scanning is more aggressive.

In corporate Windows Server environments, when npm cache or user profile directories are hosted on network file shares with centralized antivirus scanning, the network latency combined with antivirus delays can make npm install nearly impossible. In those cases, moving npm to a local drive outside scanned paths is the only practical solution.

For Docker-based development, running npm inside a container avoids Windows antivirus interference entirely, as the container's filesystem is isolated from the host's security policies.

Frequently asked questions

What does "npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocke" mean?
The EPERM error stands for "Error: PERMission Denied" and indicates that npm cannot perform a critical file operation (delete, write, rename, or link files) in your node_modules directory or npm cache. When antivirus software is the culprit, your system's security tools are actively scanning, locking, or preventing npm from completing these operations. This commonly happens because modern antivirus programs—like Windows Defender, McAfee, and Norton—monitor all file system activity in real-time, and they may flag npm's rapid creation and modification of thousands of files during package installation as suspicious or lock files that npm needs to access.
How do I fix "npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocke"?
This error occurs when antivirus software blocks npm from modifying files in node_modules. The fix involves adding your project folder to antivirus exclusions or temporarily disabling real-time protection.
What causes "npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocke"?
Windows Defender real-time protection scanning node_modules files while npm tries to modify them, causing file lock conflicts McAfee or Norton antivirus with aggressive real-time scanning interfering with rapid file creation during package extraction Windows Defender Tamper Protection feature blocking npm's write access to protected system folders
Is the "npm ERR! code EPERM npm ERR! Operation not permitted - possibly blocke" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading