DeepakVerma
DeepakVerma

Reputation: 421

Getting error "Failed to remove some directories" while installing opencv4nodejs

PS C:\Windows\system32> npm install -g opencv4nodejs
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\deepakv\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\deepakv\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\deepakv\\AppData\\Roaming\\npm\\node_modules\\opencv4nodejs\\node_modules\\opencv-build'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\deepakv\AppData\Roaming\npm\node_modules\opencv4nodejs

Installed Node Version : v14.17.1 Python Version: 2.7 Appium: 1.21.0

Upvotes: 13

Views: 71630

Answers (7)

Raphaël Balet
Raphaël Balet

Reputation: 8521

In windows, I had to

  1. Close all vsCode instance
  2. Open it as admin
  3. Run npm i again

Upvotes: 2

1.21 gigawatts
1.21 gigawatts

Reputation: 17770

Followed @Raghwendra but still had errors (possibly for different folders). Restarted the OS, opened vscode terminal and tried npm install again. This time got one directory that failed to remove as opposed to multiple last time.

...The error is ebusy so maybe if I tried again it, whatever it was, would not be busy? Ran npm install again and no error message.

Upvotes: 0

Akash Kadam
Akash Kadam

Reputation: 11

just install Node again It worked for me

Upvotes: -1

user7532054
user7532054

Reputation: 31

Another common reason for that error is that there might be a package-lock.json file generated within the project folder. To reinstall all the modules again, you may have to delete that file along with the package.json. Then, the npm install command will install all the required dependencies for the project.

Upvotes: 1

Raghwendra Sonu
Raghwendra Sonu

Reputation: 788

In order to resolve this error:

Step 1: Delete node_modules
Step 2: Delete package-lock.json
Step 3: run "npm install" command to install all the project dependencies in one shot.

It will run perfectly fine.

Upvotes: 22

Henk Kruger
Henk Kruger

Reputation: 237

Unfortunately I was unable to get this to work, even after following all the steps as suggested by Geraldo Meldo. So while this is not an answer to your problem, the workaround for me was to use yarn instead. It installed my project first time without any issues.

To install yarn globally:

npm install -g yarn

To install your project using yarn:

yarn install

I am starting to use yarn more and more as I find npm is giving me more issues than in the past.

Upvotes: 4

Geraldo Melo
Geraldo Melo

Reputation: 71

1 - Remove the Directory 'opencv4nodejs' manually 2 - After deleting the directory, return to the terminal and run the command: npm install (For me this solved it!)

This alone should resolve it. If that doesn't work, you can do the following:

1 - Delete the 'node_modules' folder manually and the package 2 - Run the command: npm init 3 - Install all libraries again

And if it still doesn't work, then before doing the first step, give full permission on the project folder you are creating first of all.

Upvotes: 7

Related Questions