0

So I just started developing with vite.js for my react app. At first I couldn't figure out why whenever I tried to run in development mode I kept getting this error

[vite] error while updating dependencies:
Error: EBUSY: resource busy or locked, rename 'H:\Dropbox\PROJECTS\website\node_modules\.vite\deps_temp' -> 'H:\Dropbox\PROJECTS\website\node_modules\.vite\deps'

After digging through some comments I found this answer suggesting that Dropbox was the problem, and for me it was. So while I can turn off file sync indefinitely and no longer have the issue, I'm wondering if there's a way I can keep file sync on and not have to deal with this.

ethan
  • 1
  • 2

1 Answers1

0

Problem: Vite relies on creating and renaming temporary folders inside node_modules

It is not just at startup of Vite. I don't think Webpack did this. (However I have come across an equivalent problem when running npm install, which also relies on renaming temporary folders.)

There is a more permanent solution than temporary pausing of Dropbox.

Solution: tell Dropbox to ignore the node_modules folder

This is a good idea anyway because:

  • it avoids filling up your online Dropbox space with duplicative node_modules content

  • it avoids unnecessary network traffic, allowing your actual source code to be sync'd sooner

  • you can always regenerate node_modules on the same or different computer, that has the sync'd package.json, by running npm install

Step 1. Run Powershell as ADMINISTRATOR

  • Start menu

  • Type "Powershell"

  • Right click "Windows Powershell", and select "Run as administrator"

  • Wait for the User Account Control window (sometimes this hides behind other windows) and approve it

Step 2. Navigate to your project folder

cd "/users/bob/dropbox/software-development/my-amazing-app/"

Step 3. Issue the Powershell command

Set-Content -Path './node_modules' -Stream com.dropbox.ignored -Value 1

Do not be alarmed if you see a lot of frantic Dropbox activity right afterwards, saying it is "Uploading files". Once it finishes this "uploading", they will be gone from the Dropbox website, and you can thereafter freely update node_modules without any further updates being sync'd.

You can do this for multiple software projects at once

Go to the parent folder, and tell Powershell to loop through all the children folders, and tell Dropbox to ignore the node_modules in each.

cd "/users/bob/dropbox/software-development/"

Get-ChildItem -Directory | ForEach-Object {
    Set-Content -Path "$($_.FullName)/node_modules" -Stream com.dropbox.ignored -Value 1
}
ProfDFrancis
  • 8,816
  • 1
  • 17
  • 26