Getting error "Failed to remove some directories" while installing opencv4nodejs
Asked Answered
L

7

10
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

Lelialelith answered 23/6, 2021 at 5:27 Comment(1)
Followed @Raghwendra but still had errors (possibly for different folders). Restarted the OS and tried npm install again. This time got one directory that failed to remove. The error is ebusy so maybe if I tried again it would not be busy. Ran npm install again and no error message.Oersted
K
16

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.

Knickknack answered 19/6, 2023 at 8:16 Comment(2)
See https://mcmap.net/q/56118/-deleting-package-lock-json-to-resolve-conflicts-quickly for a strong argument against deleting the lock file.Melpomene
Rather than deleting the entire lock file, just delete the property object for the offending package.Melpomene
B
7

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.

Banky answered 5/3, 2022 at 11:43 Comment(0)
F
3

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.

Felicitation answered 26/4, 2023 at 6:23 Comment(0)
I
1

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.

Intransigence answered 14/10, 2023 at 18:59 Comment(0)
M
1

In windows, I had to

  1. Close all vsCode instance
  2. Open it as admin
  3. Run npm i again
Mystify answered 4/4 at 12:44 Comment(0)
O
0

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.

Oersted answered 21/3 at 2:17 Comment(0)
B
-1

just install Node again It worked for me

Banister answered 20/12, 2023 at 6:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.