Another solution to the problem.
There's a package called fs.extra written by "coolaj86" on npm.
You use it like this: npm install fs.extra
fs = require ('fs.extra'); fs.move ('foo.txt', 'bar.txt', function (err) { if (err) { throw err; } console.log ("Moved 'foo.txt' to 'bar.txt'"); });
I read the source code for this thing. It tries to execute standard fs.rename() , then if it fails, it copies and deletes the original using the same util.pump() that @chandru uses.
erapert May 26 '13 at 22:40 2013-05-26 22:40
source share