How to fix npm ERR! code ETXTBSY npm ERR! ETXTBSY: text file is busy in npm
ETXTBSY occurs when npm attempts to modify or delete a file that is currently in use by another process. This is common in virtualized environments, shared folders, and VM setups.
Quick fix
Fixes ETXTBSY
npm cache clean --force
rm -rf node_modules package-lock.json
npm install- Clear npm cache and try again
- Use the --no-bin-links flag for virtual machines
- Move node_modules outside the shared folder (Vagrant/VirtualBox)
- Run npm from the host OS instead of guest VM
npm cache clean --forcerm -rf node_modules package-lock.jsonnpm installnpm ERR! code ETXTBSYnpm ERR! ETXTBSY: text file is busy
What this error means
ETXTBSY is a system-level error that occurs when npm attempts to modify or delete a file that is currently in use by another process. The error stands for 'text file is busy' and typically happens during npm install when npm tries to rename, unlink, or modify files in your node_modules directory. This error is especially common in virtualized environments, shared file systems, and situations where file locking mechanisms prevent npm from making necessary changes to package files. VirtualBox/Vagrant shared folders are particularly prone to this issue.
Typical symptoms
- npm install fails with 'ETXTBSY: text file is busy, rename' or 'unlink' error messages
- Installation process hangs or stalls before ultimately failing with ETXTBSY
- Error only occurs when running npm commands inside virtual machines or shared folders
- Multiple files report the busy status, but the actual blocking file is unclear
- npm works fine on the host OS but fails within guest VM or Docker container
Common causes
- VirtualBox/Vagrant shared folders don't support symlinks properly, causing file locking conflicts
- Running npm install inside a shared folder between host (Windows) and guest (Linux) VM
- Running npm with Node.js on Rosetta emulation on Apple Silicon Macs with certain Docker images
- Antivirus software, file indexing services, or IDEs actively scanning or locking node_modules files
- Running npm in Docker on Windows hosts without proper volume mount configuration
- npm version compatibility issues with the virtualization layer
How to fix "npm ERR! code ETXTBSY npm ERR! ETXTBSY: text file is busy"
Sometimes corrupted cache can cause file locking issues. Clear the npm cache completely and attempt a fresh install:
npm cache clean --force
rm -rf node_modules package-lock.json
npm installIf you're running npm inside a VirtualBox shared folder or VM, the --no-bin-links flag prevents npm from creating symbolic links:
npm install --no-bin-links
npm rebuild --no-bin-linksTo make this permanent, add it to your .npmrc file:
echo "bin-links=false" >> ~/.npmrcCreate the node_modules directory in the VM's home directory and link to it:
# Inside the VM
mkdir ~/node_modules
cd /vagrant/your-project
ln -sf ~/node_modules ./node_modules
npm installAlternatively, add this to your Vagrantfile to enable symlinks:
config.vm.provider "virtualbox" do |vb|
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
endIf you're using Vagrant or VirtualBox, the most reliable solution is to run npm install directly from your Windows/Mac host:
# Exit vagrant SSH and run from your host OS
exit
npm installThis avoids the file system compatibility issues entirely.
If running on Windows or Mac natively, antivirus or file indexing services might be locking files:
Windows Defender:
# Disable Windows Defender temporarily
Set-MpPreference -DisableRealtimeMonitoring $true
npm install
# Re-enable after installation
Set-MpPreference -DisableRealtimeMonitoring $falseAlternatively, exclude your project folder from real-time scanning in antivirus settings.
If npm continues to fail, switch to yarn which has better handling of file locks:
# Install yarn globally
npm install -g yarn
# Remove npm artifacts
rm -rf node_modules package-lock.json
# Install using yarn
yarn installAdvanced notes
The ETXTBSY error is fundamentally a file system permissions and symlink support issue. On Windows with VirtualBox/Vagrant, the problem occurs because Windows shares folders with Linux VMs without native symlink support, and npm tries to create symlinks in node_modules. Some Docker images on Apple Silicon Macs using Rosetta emulation have also reported this issue. For CI/CD pipelines, this error is rare because they run in proper Linux environments; if it occurs there, check that your Docker image is compatible with your host architecture.
Frequently asked questions
- What does "ETXTBSY" mean?
- ETXTBSY is a system-level error that occurs when npm attempts to modify or delete a file that is currently in use by another process. The error stands for 'text file is busy' and typically happens during npm install when npm tries to rename, unlink, or modify files in your node_modules directory. This error is especially common in virtualized environments, shared file systems, and situations where file locking mechanisms prevent npm from making necessary changes to package files.
- How do I fix "ETXTBSY"?
- ETXTBSY occurs when npm attempts to modify or delete a file that is currently in use by another process. This is common in virtualized environments, shared folders, and VM setups.
- What causes "ETXTBSY"?
- VirtualBox/Vagrant shared folders don't support symlinks properly, causing file locking conflicts Running npm install inside a shared folder between host (Windows) and guest (Linux) VM Running npm with Node.js on Rosetta emulation on Apple Silicon Macs with certain Docker images
- Is the "ETXTBSY" 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
- ๐npm Official Documentation
- ๐Docs: Node.js Error Codes(Official Docs)
- ๐ฌSO: Text file busy errors(Stack Overflow)
- ๐GitHub: npm issues(GitHub)