How to fix npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked in npm

npmINTERMEDIATEMEDIUMUpdated Dec 5, 2025· 313 views

The EBUSY error indicates that npm cannot access a file or directory because it's currently locked by another process, such as antivirus software, IDE file watchers, or cloud sync services. This is primarily a Windows-specific issue.

Quick fix

Fixes npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked

npm install
  1. Close all terminals and IDEs
  2. Clear npm cache and remove node_modules
  3. Disable antivirus or security software temporarily
  4. Check for file synchronization services
npm — error
npm install
npm ERR! code EBUSY
npm ERR! EBUSY: resource busy or locked
shell
npm install

What this error means

The EBUSY error indicates that npm cannot access a file or directory because it's currently locked or in use by another process. This is a Windows-specific issue that occurs during npm install, npm run, or other file operations when something (antivirus software, another terminal, IDE file watcher, or system process) has a lock on the node_modules directory or temporary files. Unlike other npm errors, EBUSY is an operating system-level constraint rather than a configuration issue. The file or folder npm needs to modify is being held open by another program, preventing the operation from completing. This error is almost exclusively a Windows issue because of how Windows file locking works compared to Unix-like systems. Windows uses exclusive file locks that prevent simultaneous access, while Linux/macOS use advisory locks that allow multiple readers.

Typical symptoms

  • npm install, npm run, or npm update command hangs or fails partway through
  • Error message shows EBUSY with a file path in node_modules directory
  • Running the same command again sometimes succeeds randomly
  • Error occurs even after clearing npm cache
  • Problem is specific to Windows machines (rarely occurs on macOS/Linux)

Common causes

  1. Antivirus or security software scanning node_modules files during npm operations
  2. File synchronization tools (Dropbox, OneDrive, Google Drive) holding locks on node_modules
  3. IDE or text editor file watchers monitoring the project directory
  4. Multiple terminal windows or processes running npm commands simultaneously
  5. Java process or other background application locking files in node_modules
  6. Corrupted package-lock.json or incomplete previous npm installation

How to fix "npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked"

1Close all terminals and IDEs

The simplest solution is to close all open terminals, command prompts, and IDEs accessing your project.

Visual Studio Code:
Click the trash bin icon in the terminal tab to properly close it (clicking the X may keep it running in the background).

All terminals:
Close PowerShell, Command Prompt, Git Bash, and any other terminal windows.

Then try your npm command again:

bash
npm install
2Clear npm cache and remove node_modules

Delete the node_modules directory and package-lock.json, then clear the npm cache:

powershell
# Windows PowerShell
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm cache clean --force
cmd
# Windows Command Prompt
rmdir /s node_modules
del package-lock.json
npm cache clean --force

After clearing everything, reinstall:

bash
npm install
3Disable antivirus or security software temporarily

Antivirus software like Windows Defender, AVG, Bullguard, or HP Wolf Security can lock files during scanning.

Windows Defender:
1. Open Windows Security (search in Start menu)
2. Click "Virus & threat protection"
3. Under "Virus & threat protection settings," click "Manage settings"
4. Toggle off "Real-time protection"
5. Run your npm command
6. Toggle real-time protection back on when done

If disabling antivirus fixes the issue, add your project folder to the antivirus exclusion/whitelist.

4Check for file synchronization services

Cloud storage services like Dropbox, OneDrive, and Google Drive hold locks on files while syncing:

Pause synchronization:
- Dropbox: Click the icon in system tray → Pause syncing
- OneDrive: Click the icon in system tray → More → Pause syncing
- Google Drive: Stop Google Drive temporarily

Then try npm install:

bash
npm install

Better solution: Move your project outside synced folders (e.g., to C:\Users\YourName\Projects instead of C:\Users\YourName\Dropbox\Projects).

5End blocking processes via Task Manager

Some background processes lock files in node_modules. Check Task Manager:

1. Press Ctrl+Shift+Esc to open Task Manager
2. Look for these common lock-holders:
- Java(TM) Platform SE Binary
- Electron processes
- Python processes
- Previous npm or node processes
3. Select each and click "End Task"

Or use PowerShell as Administrator:

powershell
# End all Node processes
Stop-Process -Name "node" -Force

# End all npm processes
Stop-Process -Name "npm" -Force
6Run as Administrator and restart your computer

If all else fails, run your terminal with elevated privileges and restart your system:

Run PowerShell as Administrator:
1. Press Windows key, search for "PowerShell"
2. Right-click the result and select "Run as administrator"
3. Navigate to your project directory:

powershell
cd "C:\Users\YourName\path\to\project"
npm install

Restart your computer:
This clears all file locks held by processes:

powershell
Restart-Computer

After restarting, open a fresh terminal and try npm install again.

Advanced notes

EBUSY is almost exclusively a Windows issue because of how Windows file locking works compared to Unix-like systems. Windows uses exclusive file locks that prevent simultaneous access, while Linux/macOS use advisory locks that allow multiple readers.

If you're using WSL2 (Windows Subsystem for Linux), ensure your project is inside the WSL filesystem (not a mounted Windows drive) to avoid Windows locking issues.

On NFS-mounted directories, EBUSY can occur due to how network file systems handle deleted open file handles.

Consider upgrading to Node.js 18+ and npm 8+, which have improved file locking handling. If issues persist, using a containerized environment (Docker) can completely isolate your build process from Windows file locking issues.

Frequently asked questions

What does "npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked" mean?
The EBUSY error indicates that npm cannot access a file or directory because it's currently locked or in use by another process. This is a Windows-specific issue that occurs during npm install, npm run, or other file operations when something (antivirus software, another terminal, IDE file watcher, or system process) has a lock on the node_modules directory or temporary files. Unlike other npm errors, EBUSY is an operating system-level constraint rather than a configuration issue.
How do I fix "npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked"?
The EBUSY error indicates that npm cannot access a file or directory because it's currently locked by another process, such as antivirus software, IDE file watchers, or cloud sync services. This is primarily a Windows-specific issue.
What causes "npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked"?
Antivirus or security software scanning node_modules files during npm operations File synchronization tools (Dropbox, OneDrive, Google Drive) holding locks on node_modules IDE or text editor file watchers monitoring the project directory
Is the "npm ERR! code EBUSY npm ERR! EBUSY: resource busy or locked" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading