Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js and File System on Windows - EBUSY error

I'm new to Node.js and I'm trying to figure out what is wrong with the following code.

var fs = require('fs');
var dir = "C:\\";
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
    var name = fs.statSync(dir + files[i]).name;
}

When running this code I get the error:

Error: EBUSY, resource busy or locked 'C:\hiberfil.sys'
    at Object.statSync (fs.js:424:18)
    at Object.<anonymous> (S:\start.js:7:19)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)
    at Array.0 (module.js:484:10)
    at EventEmitter._tickCallback (node.js:190:38)
like image 865
BuddyJoe Avatar asked May 25 '12 01:05

BuddyJoe


2 Answers

Hiberfil.sys is a system file that holds the hibernation data onto disk, you cannot just read it via normal rights, it's super confidential since it hold all memory information on disk.

like image 181
Mustafa Avatar answered Oct 21 '22 16:10

Mustafa


After having a similar issue without finding a sufficient answer:

I have fixed it by searching for circular dependencies.

After fixing it, I was able to run everything normally. enter image description here

like image 25
matan yemini Avatar answered Oct 21 '22 18:10

matan yemini