npm ERR! code EBUSY
This error matches known, documented patterns with reliable solutions.
Quick Fix (Most Common Solution)
- Close all editors
- Stop other npm processes
Seeing "npm ERR! code EBUSY"? 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.
What This Error Means
npm cannot access a file because it is being used.
Frequently documented in developer and vendor support forums.
Not affiliated with browser, OS, or device manufacturers.
New here? Learn why exact error messages matter →
Common Causes
- Editor has file open
- Antivirus scanning
- Another npm process
How to Fix
- Close all editors
- Stop other npm processes
- Restart computer if needed
Last reviewed: March 2026 How we review solutions
Why This Happens
EBUSY stands for "Error BUSY" and comes from the operating system when npm attempts to modify a file or directory that another process currently has locked. This is a file system-level error, not an npm-specific one—npm simply surfaces what the OS reports. On Windows, this error is significantly more common than on macOS or Linux because Windows enforces mandatory file locking: if any process has a file open for reading or writing, no other process can delete or rename that file. The most common culprit is another npm process running simultaneously—if you open two terminal windows and run npm install in both, the second process will fail with EBUSY when it tries to modify node_modules files that the first process has locked. IDE file watchers (VS Code, WebStorm) are the second most frequent cause: these tools keep handles open to files inside node_modules for indexing and IntelliSense, preventing npm from replacing or deleting those files during installation. Antivirus software on Windows is another major source—real-time scanning locks each file briefly as npm writes it, and if npm tries to rename or delete the file during that scan window, the OS returns EBUSY.
Quick Diagnostic Checklist
- Close all other terminal windows that might be running npm commands
- Close your IDE or disable its node_modules file watching temporarily
- Check for antivirus real-time scanning and exclude the project directory
- On Windows, use Task Manager to check for node.exe processes and end stale ones
- Wait 10-30 seconds and retry — the lock may be transient
Diagnosing and resolving EBUSY on Windows
# Error output:
# npm ERR! code EBUSY
# npm ERR! syscall rename
# npm ERR! path C:\Users\dev\project\node_modules\.package-lock.json
# npm ERR! errno -4082
# npm ERR! EBUSY: resource busy or locked, rename
# Step 1: Check for other npm/node processes
$ tasklist | findstr "node"
# node.exe 1234 Console 1 120,456 K
# node.exe 5678 Console 1 45,232 K <-- Stale process
$ taskkill /PID 5678 /F # Kill the stale process
# Step 2: Close VS Code (or disable node_modules watching)
# In VS Code settings.json, add:
# "files.watcherExclude": { "**/node_modules/**": true }
# Step 3: Clean and retry
$ rmdir /s /q node_modules # Remove locked directory
$ npm cache clean --force
$ npm install
# Step 4: If antivirus is the cause
# Add your project directory to Windows Defender exclusions:
# Windows Security > Virus & threat protection > Manage settings
# > Exclusions > Add folder > select your project directory
Edge Cases & Unusual Scenarios
Docker volume mount on Windows
When using Docker with Windows volumes mounted to Linux containers, file locking behaves unpredictably. npm install inside the container may fail with EBUSY on mounted volumes. Use named Docker volumes instead of bind mounts for node_modules, or run npm install inside the container with node_modules excluded from the mount.
Git hooks running npm scripts
If a pre-commit or post-merge Git hook runs npm install while you are already running npm commands, both processes compete for the same files. Disable hooks temporarily with git commit --no-verify or serialize the operations.
OneDrive or Dropbox syncing node_modules
Cloud sync tools like OneDrive and Dropbox lock files during upload. If your project is inside a synced folder, npm cannot modify files that are being uploaded. Move projects outside synced folders or exclude node_modules from syncing.
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?
Frequently Asked Questions
How do I find what locks files?
Use lsof on Mac/Linux or Process Explorer on Windows.
Can I force npm?
Better to find and close the locking process.
Why does EBUSY happen more on Windows than macOS or Linux?
Windows uses mandatory file locking—any process reading a file prevents other processes from deleting or renaming it. macOS and Linux use advisory locking, which allows processes to modify files even if another process has them open.
Can I prevent EBUSY errors permanently?
Exclude your project directory from antivirus scanning, disable IDE file watching for node_modules, and avoid running multiple npm processes in the same project. These three steps eliminate the vast majority of EBUSY errors on Windows.
Is it safe to force-delete node_modules when EBUSY occurs?
Yes, deleting and recreating node_modules is always safe. If rmdir fails because of locks, try closing all terminals and IDEs first, or restart your machine to release all file handles. Then run npm install fresh.
Related Resources
Also Known As
- npm install error
- npm dependency error
- node package manager error
- npm ERR! message
Common Search Variations
- "npm install not working"
- "npm ERR how to fix"
- "node modules error fix"
- "npm install failed what to do"
- "npm dependency conflict solution"
- "why does npm install fail"
Related Errors
Still Stuck?
Paste a different error message or upload a screenshot to get help instantly.